Hey guys I am new in Javascript as well as in this site. I have a small problem hope you guys can help me out
I will give a small example of the problem
[code=html]<html><body>
<form name=”form”>
<input type=”button” onclick=”addInput()” name=”add” value=”Add more rows” />
</form>
<div id=”row”>
<input name=”qty” type=’text’ value=”” /> <br /> // This is the quantity field
<input name=”price” type=’text’ value=”” /> // this is price field
<input name=”total” type=’text’ value=”” /> // This field should multiply the values of qty and price
</div>
<div id=”row”>
<input name=”qty” type=’text’ value=”” /> <br /> // This is the quantity field
<input name=”price” type=’text’ value=”” /> // this is price field
<input name=”total” type=’text’ value=”” /> // This field should multiply the values of qty and price
</div>
<input name=”grandTotal” type=’text’ value=” />
</body>
</html>
Now in the above code there are two set of rows containing input fields
I have used the same name in the input field cuz in future if a user clicks on a Add more row he can have as many as he wants so how do I apply addition in all the generated fields dynamically using javascript and display in in the an answer input. this is just an example I will have more fields in the same form but just to be on point I have written this example.
Now what I want to know here is how to multiply the qty and price field and display the answer in the total field. And then add the total fields and display the answer in grandTotal field.
Hope I didn’t confuse and you guys and would provide me an easy solution.