Creating A Formula Page

Today I had my first site maintenance problem. My price quote calculator went down. The calculator relied on a third party app (luminfish calculator). Not wanting clients to see my site as broken or flawed I immediately began working on a fix. What I ended up doing was writing a Corvid (javascript with custom WIX APIs) code to calculate the values I needed. For those of you interested in the Corvid code for a calculator, I'll include it below. This experience taught me to avoid relying on third party apps whenever possible

import wixData from 'wix-data'; $w.onReady(function () {//function which runs while page lods to give initial input //TODO: write your page related code here... $w("#text19").text = ("$ " + Number(calculateCost(($w("#input1").value), ($w("#input2").value), ($w("#input3").value), $w("#checkbox1").checked))); }); function calculateCost(pages, major, minor, SEO) { var S; if (SEO === true) { //sets S value to make math work for SEO S = 10; } else { S = 0; } var totalCost = (pages * 75) + (S * pages) + (major * 150) + (minor * 25); return totalCost } export function Pages(event) { //on input function for pages $w("#text19").text = ("$ " + Number(calculateCost(($w("#input1").value), ($w("#input2").value), ($w("#input3").value), $w("#checkbox1").checked))); } export function majInput(event) { //on input function for major features $w("#text19").text = ("$ " + Number(calculateCost(($w("#input1").value), ($w("#input2").value), ($w("#input3").value), $w("#checkbox1").checked))); } export function MinInput(event) { //on input function for minor features $w("#text19").text = ("$ " + Number(calculateCost(($w("#input1").value), ($w("#input2").value), ($w("#input3").value), $w("#checkbox1").checked))); } export function SEO(event) { //on change function for SEO checkbox $w("#text19").text = ("$ " + Number(calculateCost(($w("#input1").value), ($w("#input2").value), ($w("#input3").value), $w("#checkbox1").checked))); }

7 views0 comments

Recent Posts

See All

Jack's Tech Help is Booming this Summer

Jack's Tech Help is up and running in full swing and accepting clients! We've received nothing but five-star reviews and we're ready to help you! Book a consultation now.

JTH prepares for a new product line

A new product line of monthly maintenance plans and marketing tools is set to unveil this week. The JTH team is working hard to deliver these features to you quickly and effectively. Stay tuned for t