sunny
08-12-2009, 06:24 PM
Hi there,
i have tried to make a bill type form with the following code
<form name='form'>
<table border=1>
<tr>
<th>particulars</th>
<th>rate </th>
<th>quantity</th>
<th>Total</th>
</tr>
<tr>
<td>Product 1</td>
<td><input type="text" name="rate1" size=3></td>
<td><input type="text" name="quantity1" size=3></td>
<td><input type="text" name="total1" size=3></td>
</tr>
<tr>
<td>Product 2</td>
<td><input type="text" name="rate2" size=3></td>
<td><input type="text" name="quantity2" size=3></td>
<td><input type="text" name="total2" size=3></td>
</tr>
<tr>
<td colspan=3 align="right">Tax : </td>
<td><input type="text" name="tax" size=3></td>
</tr>
<tr>
<td colspan=3 align="right">Grand Total : </td>
<td><input type="text" name="gtotal" size=6></td>
</tr>
</table>
</form>
What i want is the amount in rate and quantity be multiplied and should come up in total coloumn and later, after tax amount is entered ,tax should be taken to calculate grand total.
I used a function like this :
<script>
function tot1()
{
var tot1;
var r1=document.form.rate1.value;
var qty1=document.form.quantity1.value;
tot1=r1*qty1;
// can we multiply two var like this or we need to use something else?
document.form.tot1.value =total1;
}
</script>
the product wise total will be called after quantity coloumn calls for Onblur event or something of that sort.
What's going wrong ???
and Can this be achieved by one function ????
Thanks.
i have tried to make a bill type form with the following code
<form name='form'>
<table border=1>
<tr>
<th>particulars</th>
<th>rate </th>
<th>quantity</th>
<th>Total</th>
</tr>
<tr>
<td>Product 1</td>
<td><input type="text" name="rate1" size=3></td>
<td><input type="text" name="quantity1" size=3></td>
<td><input type="text" name="total1" size=3></td>
</tr>
<tr>
<td>Product 2</td>
<td><input type="text" name="rate2" size=3></td>
<td><input type="text" name="quantity2" size=3></td>
<td><input type="text" name="total2" size=3></td>
</tr>
<tr>
<td colspan=3 align="right">Tax : </td>
<td><input type="text" name="tax" size=3></td>
</tr>
<tr>
<td colspan=3 align="right">Grand Total : </td>
<td><input type="text" name="gtotal" size=6></td>
</tr>
</table>
</form>
What i want is the amount in rate and quantity be multiplied and should come up in total coloumn and later, after tax amount is entered ,tax should be taken to calculate grand total.
I used a function like this :
<script>
function tot1()
{
var tot1;
var r1=document.form.rate1.value;
var qty1=document.form.quantity1.value;
tot1=r1*qty1;
// can we multiply two var like this or we need to use something else?
document.form.tot1.value =total1;
}
</script>
the product wise total will be called after quantity coloumn calls for Onblur event or something of that sort.
What's going wrong ???
and Can this be achieved by one function ????
Thanks.