
Originally Posted by
bdmovies
Any ideas as to why the length of 1 checkbox is undefined?
Because a single element doesn't form an array. Also your loop is potentially skipping array elements. You can do it like this:
Code:
if(theForm.servee.length)
{
for (var i=0, j=0; i < theForm.servee.length; i++)
if(theForm.servee[ i ].checked == true)
serviceID[ j++ ] = theForm.servee[ i ].value;
}
else
if(theForm.servee.checked)
serviceID[0] = theForm.servee.value;
or you could use Array.push.
Where used, return should be executed unconditionally and always as the last statement in the function.
That's my signature, it's not part of the damn post!
Bookmarks