top of page
Search

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))); }

35 views0 comments

Recent Posts

See All

Are you in need of a talented copywriter for your business? Look no further – Jack's Tech Help is proud to announce that we are now offering copywriting services! Copywriting is an essential component

Hi all! I wanted to give a brief update of what Jack's Tech Help is looking like starting 2022. Looking short term: Jack's Tech Help's JTH maintenance plans have taken off and are accounting for nearl

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.

bottom of page