Hi,
Location: the web page in question
History: I had two different forms on two different pages. I was told to put them onto one web page, so that one form up is high on the page and the other form is near the bottom. Both forms just have checkboxes for registering for classes. Previously on each page, there was javascript that made sure that at least one class was chosen.
Now: I put both forms on one web page and, as requested, are separated vertically by much space. Programmatically, I decided to do away with the two forms and consolidate them. I did this by deleting the ending form tag (</form>) for the first form and the beginning form tag (<form action=âŚ>) for the second form. Programmatically, there is now only 1 form on the web page although physically it still looks like 2 separate forms.
Each section of the form has itâs own âNextâ button (a submit tag). Why? Because if the user is looking at the upper form, they only see that section of the form and they may want to go ahead and sign up for the class. Likewise, if they only see the lower form, they will need a submit button there as well. That doesnât seem to be the problem. I can hit either submit button and get to the next page fine.
Problem: My problem is that now, in Netscape Navigator, after programmatic form consolidation, the javascript that verifies that at least one class has been chosen has suffered trauma.
Specifically, the top âformâ and itâs âNextâ button work in that it flags an error if no classes are chosen but submits fine when at least one class is chosen.
This is not true of the bottom âformâ. It always flags an error even if one class is chosen from it.
You might want to tell me to keep the forms separate but here is why I did not: I want the user to be able to choose classes in both forms if they realize that there are 2 forms to choose from on this page without having to fill out their names and info 2 separate times. That way, they can be linked to either the top or bottom form from some other web page, pick a class, see the link that states that there are even more classes, choose one of those additional classes, press the âNextâ button, and see all their classes on the next screen.
Code:
Code:
function checkForm(theForm)
{
if (! checkCheckboxGroup(theForm,'chosenClass[]')) return false
}
function checkCheckboxGroup(theForm,theGroupname) {
var theElements = theForm.getElementsByTagName("input");
for (var i = 0; i < theElements.length; i++)
{
if (theElements[i].type == 'checkbox' && theElements[i].name == theGroupname && theElements[i].checked)
return true
}
//alert ('No checkboxes with name "' + theGroupname + '" are checked.');
return false
}
function submitIt(someForm)
{
//make sure they enter a class
if (checkCheckboxGroup(document.forms.theForm,'chosen Class[]') == false)
{
alert("You must select at least one class.");
return false
}
return true
}
Any ideas?
Thank you very much for reading all of this!