Hi all,
I'm trying to add up all numbers entered on a child form, then populate that sum into a field on the parent form. I can transfer a single number only. When multiple numbers (from multiple text fields on the child) are filled in...they are "stringed" together onto the parent form. Not added together.
Here's my javascript code so far:
function fillValue() {
window.opener.document.forms[0].elements[1].value = ""
var rentTotal = ""
var tempTotal = ""
var elemLen = myform.elements.length
for (var x=0;x<elemLen;x++) {
//alert(myform.elements[x].value)
tempTotal = myform.elements[x].value
if (tempTotal > 0) {
theTotal = theTotal + tempTotal
//Also tried these
//theTotal = (theTotal + tempTotal)
//theTotal =+ tempTotal
}
}
window.opener.document.forms[0].elements[1].value = theTotal
return true;
}
Any ideas on why the numbers aren't being added, but instead being concatenated together in a string?
Thanks.
I'm trying to add up all numbers entered on a child form, then populate that sum into a field on the parent form. I can transfer a single number only. When multiple numbers (from multiple text fields on the child) are filled in...they are "stringed" together onto the parent form. Not added together.
Here's my javascript code so far:
function fillValue() {
window.opener.document.forms[0].elements[1].value = ""
var rentTotal = ""
var tempTotal = ""
var elemLen = myform.elements.length
for (var x=0;x<elemLen;x++) {
//alert(myform.elements[x].value)
tempTotal = myform.elements[x].value
if (tempTotal > 0) {
theTotal = theTotal + tempTotal
//Also tried these
//theTotal = (theTotal + tempTotal)
//theTotal =+ tempTotal
}
}
window.opener.document.forms[0].elements[1].value = theTotal
return true;
}
Any ideas on why the numbers aren't being added, but instead being concatenated together in a string?
Thanks.