Hi there,
i have tried to make a bill type form with the following code
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.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>
I used a function like this :
the product wise total will be called after quantity coloumn calls for Onblur event or something of that sort.Code:<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>
What's going wrong ???
and Can this be achieved by one function ????
Thanks.



Reply With Quote
Bookmarks