Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiplying values
    text
    copied!<p>Im using the following method to add up text boxes. I have tried changing multiple things and cant seem to multiply two text box values! essential I want 2 text box that values are multiplied and displayed in a third text box. I want this value to be fluid aka change when the number changes! I was using this code because i may be multiplying more then one thing but if this is too much of a hassle i will live with just multiplying two at a time</p> <p>The code im using to add is </p> <pre><code> &lt;!--adding script #--&gt; &lt;script&gt; $(document).ready(function(){ calculateSum(); //iterate through each textboxes and add keyup //handler to trigger sum event $(".txt").each(function() { $(this).keyup(function(){ calculateSum(); }); }); }); function calculateSum() { var sum = 0; $("#sum").val(sum.toFixed(2)); //iterate through each textboxes and add the values $(".txt").each(function() { //add only if the value is number if(!isNaN(this.value) &amp;&amp; this.value.length!=0) { sum += parseFloat(this.value); } }); //.toFixed() method will roundoff the final sum to 2 decimal places $("#sum").html(sum.toFixed(2)); var total = document.getElementById("subtotal").value == ""; var total = document.getElementById("subtotal").value = sum; } &lt;!--END adding script #--&gt; </code></pre> <p>I tried setting the last line to</p> <pre><code> var times1 = document.getElementById(subtotal); var times2 = document.getElementById(tax); var equal = times1.value * times2.value; </code></pre> <p>and then changing var total1 = document.getElementById("total1").value = sum9; to var total1 = document.getElementById("total1").value = equal;</p> <p>The text boxes id are subtotal and tax the box im trying to update is total1.</p> <p>Thanks alot!</p>
 

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