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="">

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...

Primo. Damn so simple. Thanks mate

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.