I am not sure why this is alluding me but here it is. I need to test for the existence of a form field using javascript.
I have tried
if (document.getElementById(fldName)!= ‘null’)
if (document.getElementById(fldName)!= ‘undefined’)
I am needing to cycle through a set of form fields – that may or may not exist and add up there totals and alert the user of having hit the maximum.
This is the actual function… ( any ideas)
function checkNutrition(){
var intTotal = 0
for(i=24;i<=53;i++)
{
var fldName = “act_ID” + i;
if (document.getElementById(fldName)!= ‘null’){
if (document.getElementById(fldName).checked){
intTotal += document.getElementById(fldName).value;
}
}
}
if (intTotal >10){
alert(‘You have selected more than 10 nutrition points – please revist.’);
return false;
}else{
return true;
}
}
Thanks so much!
Chris Luksha
Echo Web Services
Making Your Website Resound
603-831-0099
[url]http://www.echowebservices.com/
And did I mention I Love building Cartweaver Modules
Shop Amazon Today!
[url]http://tinyurl.com/ymh3tc