Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Prototype does not have a no conflict mode..</p> <p>I've converted your code, but I may have missed a spot or two..</p> <p>Generally, <code>$('elemID')</code> => <code>$('#elemID')</code> and <code>$F('elemID')</code> => <code>$('#elemID').val()</code> is what I've done..</p> <pre><code>// JavaScript Document // calculate price based on quantity function changeQty(change){ var currentQty = parseInt($('#quant').val()) // Where quant is the id of your quantity input field. Gets value of currentQty field switch (change) { case 'add': currentQty += 1 $('#quant').val(currentQty) calculate() break case 'subtract': if (currentQty &gt; 1) { // only subtract if qty is greater than zero currentQty -= 1 $('#quant').val(currentQty) calculate() } break case 'field': if (currentQty &gt; 0) { window.setTimeout('calculate()', 500) } break } } function calculate(){ var currentQty = parseInt($('#quant').val()) // Where quant is the id of your quantity input field. Gets value of currentQty field var jsnormalprice = $('#jsnormalprice').val() // Where jsnormalprice is the id of your hidden base price field. Gets value of base_price field var jsspecialprice = $('#jsspecialprice').val() // Where is the id of your hidden base price field. Gets value of base_price field if (currentQty &gt; 0) { // Don't want price to display if zero if customer zeros out quantity var new_jsnormalprice = jsnormalprice * currentQty // Calculate the price. var new_jsnormalprice = new_jsnormalprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down. var new_jsspecialprice = jsspecialprice * currentQty // Calculate the price. var new_jsspecialprice = new_jsspecialprice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down. } else { // set price back to original price new_jsnormalprice = jsnormalprice new_jsspecialprice = jsspecialprice } $('#jsnormalpriceshow').html(new_jsnormalprice) // Where jsnormalpriceshow is the id of your span for the echoed product price $('#jsspecialpriceshow').html(new_jsspecialprice) // Where jsspecialpriceshow is the id of your span for the echoed product price } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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