0

Hi All Im trying to get this to work, but can only get it to work without putting the form tags in, and wont work with more than one set of the inputs.
the below is the result when i use ajax to search for item names, then want to caluculate the quantity * length (for total quantity), then total quantity * rrp_exc. the result should show in the the total field. It works, but not if the form tags are in and if there are multiple rows of the below inputs, eg, when there is more than one item retrieved in the search. any help would be great.

<script type="text/javascript">
function total()
{
var a = document.getElementById("rrp_exc");
var b = document.getElementById("quantity");
var e = document.getElementById("length");
if(a.value=="")
{
a.value = 0;
}
if(b.value=="")
{
b.value = 1;
}
if(e.value=="")
{
e.value = 1;
}
var f = b.value * e.value;
var d = a.value * f;
document.getElementById("total").value=d;
}
</script><input type="text" name="" id="rrp_exc" value="" onkeyup="total()">
<input type="text" id="quantity" name="" value="" onkeyup="total()">
<input type="text" id="length" name="" value="" onkeyup="total()">
<input type="text" name="" id="total" value="">
2
Contributors
3
Replies
9
Views
5 Years
Discussion Span
Last Post by gotboots
0

Is the script tag in the <head> tag and was your form tag in your <body> tag? It doesn't seem so? That would be my guess...

0

Would you know how to change it so if I had multiples of the same form? With id, if you use for example the third one down, it does the answer in the top form, rather than the third.
If not, sweet as, cos I can use this anyway okay

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.