Hi guys, I am trying to create a Javascript price calculator based on the users input, plus I need it to do some math... So the price per item is $1.00 per 1000 units. So if the buyer enters in 1000, the calculator will change the amount hidden field to 1.00, and the cost div to 1.00 also. HTML: I want to buy <input type="text" class="fieldbox" style="width: 150px;" name="userinput"> items. Your total cost is: <div id="cost">($)</div> <input type="hidden" name="amount" value="AMOUNT BASED ON USER INPUT"> HTML: I am very new to JS so any help would be great!
You can do something like the below code I want to buy <input type="text" class="fieldbox" style="width: 150px;" name="userinput" onKeyUp="performMath(this.value)"> items. Your total cost is: <div id="cost">($)</div> <input type="hidden" name="amount" id="amount" value="AMOUNT BASED ON USER INPUT"> <script type="text/javascript"> function performMath(value) { document.getElementById('cost').innerHTML= value/1000; document.getElementById('amount').value = value/1000; } </script> Code (markup):