Hi, i am new to javascript and i am doing an order form for my assignment.
[B]The order form basic structure is this:
[B]quantity01 * 100 = subtotal01
quantity02
grand total = subtotal01 + subtotal02
I have done the first two parts but when i did the third one i got stucked.
[B]The problem is just the result of subtotal01 + subtotal02 resulting subtotal01subtotal02
so for example; [B]200 + 200 = 200200 instead of giving me 400
The code is below: Thank you
<HEAD>
<script type=”text/javascript”>
<!– Begin
function startCalc(){
interval = setInterval(“calc()”,1);
}
function calc(){
one = document.orderform01.quantity01.value;
two = 100
three = document.orderform02.quantity02.value;
document.orderform01.subtotal01.value = (one) * (two);
document.orderform02.subtotal02.value = (three)
price01 = document.orderform01.subtotal01.value
price02 = document.orderform02.subtotal02.value
grandtot = ((price01) +(price02))
document.orderform03.grand_total.value = grandtot
}
function stopCalc(){
clearInterval(interval);
}
</script>
</HEAD>
<BODY>
<form name=”orderform01″>
<table border=”1″>
<tr>
<td> <input type=text name=”quantity01″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> </td>
<td width=”128px”> 100 </td>
<td> <input type=text name=”subtotal01″> </td>
</tr>
</form>
<form name=”orderform02″>
<table border=”1″>
<tr>
<td> <input type=text name=”quantity02″ value=”” onFocus=”startCalc();” onBlur=”stopCalc();”> </td>
<td width=”128px”> 100 </td>
<td> <input type=text name=”subtotal02″> </td>
</tr>
</form>
<form name=”orderform03″>
<table border=”1″>
<tr>
<td width=”280px”> Total </td>
<td width=”146px”> <input type=text name=”grand_total” value=”” /> </td>
</tr>
</table>
</form>