I have a javascript test function to determine if items have been entered but it appears that the function never completes, it runs the for loop but not the items after it??? I can produce a screen capture video of the events that happen, contact me and I will send a link to my download area. All of the code outside of the for loop (the last 5 lines) does not get executed???
here is the function that is triggered by a mouseover:
function testChecked(form) {
var noneselected = 0;
var errmsg = '';
var iserror = 0;
var formcount = document.forms.length;
alert('initial form length:' + formcount);
for ( var cntr = 0; cntr <= formcount; cntr++ ) {
if ( form['itemid'+(cntr+1)].checked ) {
if ( form['selectterm'+(cntr+1)].value == 'select' ) {
errmsg += 'You have checked but did not select a term for item: ' + (cntr+1) + '\n';
iserror = 1;
form['selectterm'+(cntr+1)].style.background = 'yellow';
} else {
errmsg += 'You have checked and selected: ' + (cntr+1) + form['selectterm'+(cntr+1)].value + '\n';
iserror = 1;
}
} else {
if ( form['selectterm'+(cntr+1)].value != 'select' ) {
errmsg += 'You have selected a term but did not check item: ' + (cntr+1) + '\n';
form['selectterm'+(cntr+1)].style.background = 'yellow';
iserror = 1;
} else {
errmsg += 'You have NOT checked and NOT selected: ' + (cntr+1) + form['selectterm'+(cntr+1)].value + '\n';
}
}
alert('at end of loop form length:' + formcount);
alert('inside cntrs:' + iserror + ' | ' + noneselected + '\n');
alert(errmsg);
}
alert('outside cntrs:' + iserror + ' | ' + noneselected + '\n');
alert ('nothing has been selected2');
if ( noneselected == 1 ) {
alert ('nothing has been selected1');
}
if ( iserror == 1 ) {
alert (errmsg);
}
}