Currently I have a function that adds all input within a div (inputsite) and then subtracts that total from another input (siteinput). This worked great, but I have added more inputs to the div that will contain text; this will invoke the "not a readable number" alert:
function site_change() {{
var sites= document.getElementById('sitesinput').value;
var sum= 0;
var inputs= document.getElementById('inputsite').getElementsByTagName('input');
for (var i= inputs.length; i-->0;) {
var v= inputs[i].value.split(',').join('.').split(' ').join('');
if (isNaN(+v))
alert(inputs[i].value+' is not a readable number');
else
sum+= +v;
}
var phones= document.getElementById('phonesinput').value;
document.getElementById('siteresult').innerHTML = phones-sum;
};
}
An example of input that needs to be included is:
<input name="site1" type="text" size="3" value="0" />
And this needs to be excluded:
<input name="site1PC" type="text" size="7" maxlength="7"/>
How do I adjust the function so that it only picks up the ones named site1, site2, site3, etc and not site1PC, site2PC, site3PC, etc?
Thanks, Ben.