javascript - need to calculate 2 input fields and display in 3rd -


i want multiply quantity price , 'display' in total. total needs named "amount" in order transfer total cost gateway. can see i'm trying create around able use quantity.

all information here test purposes isn't personal.

<script type="text/javascript"> function totalprice() {     var qty = document.getelementbyid("quantity").value;     var price = 219999;     var total = (qty * price);     document.getelementbyid("tot").value = total; } </script>  <form action="https://gateway.charityclear.com/hosted/" method="post">  <input type="hidden" name="merchantid" value="0000992"> <input type="hidden" name="countrycode" value="826">  <input type="hidden" name="currencycode" value="826">   <table> <tr> <td>full name </td><td><input type="text" name="customername" value=></td></tr> <tr> <td>full shipping address <br>(including country)<br>(must same billing     address)</td><td><textarea rows="4" name="customeraddress" value=></textarea></td></tr> <tr> <td>post code </td><td><input type="text" name="customerpostcode" value=></td>          </tr> <tr> <td>email address </td><td><input type="text" name="customeremail" value=></td> </tr> <tr> <td>phone number <br>(required delivery)</td><td><input type="text" name="customerphone" value=></td></tr>  <input type="hidden" name="redirecturl" value="http://www.ukrobstep.com/order- successful.html"> <tr><td></td> </tr> <tr><td><input type="hidden" name="orderref" value="colour">colour</td> <td> <select name="orderref"> <option value="select colour">select colour <option value=" robin m1 in black">black <option value=" robin m1 in white "> white <option value=" robin m1 in red"> red <option value=" robin m1 in yellow ">yellow <option value=" robin m1 in silver/grey "> silver/grey </select></td> </tr> <tr><td>  quantity</td><td><input type="text" name="quantity" id="quantity" class="field"  value="1" /></td></tr> <tr><td>price per unit</td><td><input type="text" name="price" id="price" class="field" value="£2199.99" readonly="readonly"/> <input type="hidden" name="amount" id="tot" class="field" value=""/> </td></tr>  </table> <input type="image" src="http://www.weebly.com/uploads/9/8/2/8/9828047/5792561_orig.png" border="0" alt="pay now" >  </form> 

i hope can help, in advance.

use parseint();

example

function totalprice() {     var qty = document.getelementbyid("quantity").value;     var price = 219999;     var total = (parseint(qty) * price);     -------------^^^^^^^^^--------------     document.getelementbyid("tot").value = total; } 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -