Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>YUCK! Why on earth are you tippling through multiple functions?</p> <p><code>GetPriceFive()</code> calls PriceTwo which doesn't exist at that point. What you're trying to do is a complete bastardisation of programming. Here's a fresh start for you:</p> <pre><code>function calculate(PricingForm) { height = PricingForm.height.value; width = PricingForm.width.value; photos = PricingForm.photos.value; lgtext = PricingForm.lgtext.value; mountlam = PricingForm.mount.value; mountlam = PricingForm.lam.value; price = GetPrice(PricingForm, height, width, photos, lgtext, mount, lam) document.PricingForm.collageEstimate.value = "$" + RoundToPennies(price); } function GetPrice(PricingForm, height, width, photos, lgtext, mount, lam) { price = height * width; price = price / 144; pricetwo = price; // for lookup later price = price * 15; price = price + (PricingForm.lgtext.checked) ? 20 : 0; price = (PricingForm.mount.checked) ? price + pricetwo * 5 : price; price = (PricingForm.lam.checked) ? price + pricetwo * 5 : price; return (photos * 4.95) + price; } function RoundToPennies(n) { pennies = n * 100; pennies = Math.round(pennies); strPennies = "" + pennies; len = strPennies.length; return strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len); } </code></pre> <p>That should do what your old code did (perhaps with a couple of oversights), without all the guff... And you have a lasting reference to the second price.</p> <p>I dumped the write function because it wasn't needed. Functions that take up one line and are only called once don't need to be functions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload