javascript - Calculate and add data in to input fields -



javascript - Calculate and add data in to input fields -

so have fields:

<input type="text" id="price" name="price"> <input type="text" id="taxpercentage" name="taxpercentage"> <input type="text" id="taxpaied" name="taxpaied"> <input type="text" id="totalprice" name="totalprice">

after add together cost , taxation percentage want taxpaied , totalprice field automatically filled calculated values.

ex: if cost = 200 , taxpercentage = 24 lastly 2 fields should filled 48 , 248.

i think possible javascript didn't find online.

try one....

<input type="text" id="price" name="price" onchange="calculate()"> <input type="text" id="taxpercentage" name="taxpercentage" onchange="calculate()"> <input type="text" id="taxpaied" name="taxpaied"> <input type="text" id="totalprice" name="totalprice"> <script> function calculate() { var price=document.getelementbyid("price").value; var tax=document.getelementbyid("taxpercentage").value; if(price == "" || taxation =="") { homecoming false; } var taxpaied=document.getelementbyid("taxpaied"); var totalprice=document.getelementbyid("totalprice"); taxpaied.value = (price/100)*tax; totalprice.value = (price * 1) + (taxpaied.value * 1); } </script>

javascript html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -