hi,
I have 3 inputs for quantities to be entered by user, then when user enters a quantity , I should get 2 results ; one in the first add-on total input textfield which is the quantity entered by user multiply by the fixed price for the first add-on (eg.3.75). and the other result should appear in the last input textfield called (subtotal) which is the result of whatever user enter in quantity textfield multiply by the fixed price pluse the base price (eg.43.99).
<html dir="ltr">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Bear Toys</title>
<script type="text/javascript">
function alertInput1()
{
var qty1 = document.getElementById("input1").value;
if (qty1<0 )
{
alert("Quantity should be => 0");
return 0;
}else{
return qty1* 3.57();
}
}
function alertInput2()
{
var qty2 = document.getElementById("input2").value;
if (qty2<0 )
{
alert("Quantity should be => 0");
return 0;
}else{
return qty2 *alertTot2();
}
}
function alertInput3()
{
var qty3 = document.getElementById("input3").value;
if (qty3<0 )
{
alert("Quantity should be => 0");
return 0;
}else{
return qty3 * alertTot3();
}
}
function alertTot1()
{
var tot1 = document.getElementById("input1").value;
return input1 * 3.57;
}
function alertTot2()
{
var tot2 = document.getElementById("input2").value;
return input2 * 2.80;
}
function alertTot3()
{
var tot3 = document.getElementById("input3").value;
return input3 * 3.00;
}
function subTotal()
{
var sub = document.getElementById("sub").value;
return 43.99() ;
}
</script>
</head>
<body>
<form name="formInput" method="post" action="page33.jsp">
<p align="center">Bear Toys</p>
<p align="center">
<img border="0" src="bear2.jpg" width="156" height="167"></p>
<p align="center" dir="ltr">Base Price= $43.99</p>
<p align="center" dir="ltr"> </p>
<p align="center">
</p>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="178" align="center">
<p>Add-on</td>
<td width="213">
<p align="center">Quantity</td>
<td width="183" align="center">Add-on Price</td>
<td> Add-on Total</td>
</tr>
<tr>
<td width="178" align="center">Angel card game</td>
<td width="213">
<p align="center"><input type="text" name="input1" onchange= "formInput.tot1.value = alertInput1(), formInput.sub.value = subTotal()"></td>
<td width="183" align="center">$3.57 </td>
<td><input type="text" name="tot1" value=""></td>
</tr>
<tr>
<td width="178" align="center">Necklace kit </td>
<td width="213">
<p align="center"><input type="text" name="input2" onchange="alertTot2()"></td>
<td width="183" align="center">$2.80</td>
<td><input type="text" name="tot2" value=""></td>
</tr>
<tr>
<td width="178" align="center">Wood kit</td>
<td width="213">
<p align="center"><input type="text" name="input3" onchange="alertTot3()"></td>
<td width="183" align="center"> $3.00</td>
<td><input type= "text" name="tot3" value=""></td>
</tr>
<tr>
<td width="178"> </td>
<td width="213">
</td>
<td width="183" align="center">Subtotals</td>
<td><input type= "text" name="sub" ></td>
</tr>
</table>
<p align="center">
</p>
<p align="center">
<input type="submit" value="Submit" name="buttonsubmit">
</p>
</form>
</body>
</html>