Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the textbox value when dropdown box value changed in javascript
    text
    copied!<p>I am having the table which contains the table like</p> <blockquote> <p>items&nbsp; price&nbsp; quantity&nbsp; total</p> <p>apple&nbsp;&nbsp;&nbsp; 100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200</p> <p>orange&nbsp; 200&nbsp;&nbsp;&nbsp; 2 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 600</p> <p>grand total=600.</p> </blockquote> <p>item fields are dropdown when drop down changes the price will be changed and total value and grandtotal also changed. My problem is when selecting apple and orange again go to apple change the item my grand total is not changing.</p> <p><strong>My Javascript code:</strong></p> <pre><code>function totalprice(element, price) { var elementid = element.id; var expr = elementid.substring(elementid.indexOf(":") + 1, elementid.length); var quantity = document.getElementById("quantity:" + expr).value; var price = document.getElementById("price:" + expr).value; if (quantity &gt; 0) { document.getElementById("total:" + expr).value = (parseInt(quantity)) * (parseInt(price)); var grandtotal = document.getElementById("total:" + expr).value; var gtot = 0; var amount = 0; for (var i = 0; i &lt;= expr; i++) { //document.getElementById("total").value=""; gtot = document.getElementById("total:" + expr).value; amount = parseInt(gtot) + parseInt(amount); } document.getElementById("total").value = amount; } return true; } </code></pre> <p>I know the mistake is in for loop only it is simple one but i dont know how to solve.</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