stephenbruceburch
Technical User
I'm trying to learn javascript and did an example from a book and I can't get it to work. It doesn't put the numbers back into the txtTotalTax and txtTotalCost text fields. And I don't know what I am doing wrong. It looks like the other examples and they all worked. Any help would be great appreciated.
<script language="javascript">
var intPrice, intTax, intTotalTax, intTotalCost;
function calculateJS(){
intPrice = document.frmJS.txtPrice.value;
intTax = document.frmJS.txtTax.value;
intTotalTax = intPrice * intTax;
document.frmJS.txtTotalTax = intTotalTax;
intTotalCost = (1 * intPrice + intTotalTax);
document.frmJS.txtTotalCost.value = intTotalCost;
}
</script>
<h3>Calculate the Tax</h3>
<form name="frmJS">
<input type="text" name="txtPrice" maxlength="7">
Product Price<br>
<input type="text" name="txtTax" value=".085" maxlength="7">
Percent Tax (0.085)<br>
<input type="text" name="txtTotalTax" maxlength="7">
Total Tax in Dollars<br>
<input type="text" name="txtTotalCost" maxlength="7">
Total Cost of the Product<br>
<input type="button" name="btnButton" value="Calculate my Total" onClick="calculateJS();">
</form>