Due to a need to support Netscape 4.7, I'm locked into some very limited options for a project I'm working on.
I have a list of book titles that could be numbered in the 100s depending on user choices in an online order application. For each book title, the user must indicate a format (there are five choices, ie: hardcover, large print...) and a quantity for each format. I need to validate the form to be sure each book has a quantity indicated for at least one format type. I am using a "For" loop to go through the 5 format choices for each book on the list. If any title fails to have a format choice, I am revealing a graphic error message next to that title. If all titles have a format chosen, I want to submit the form. I am having trouble finding a way to submit the form only at the completion of the validation effort. If the user has to correct more than one entry on the form, my script submits upon every correction that is made. I need help writing a function that submits only once.
Here is what I am doing ATM:
function ValidateBindings(){
for(x = 1; x <= recordsReturned; x++){
bindingHC = eval("document.interactiveForm.hardcover00" + x + ".value");
bindingLP = eval("document.interactiveForm.largeprint00" + x + ".value");
bindingUC = eval("document.interactiveForm.UCassette00" + x + ".value");
bindingACD = eval("document.interactiveForm.ACD00" + x + ".value");
bindingUCD = eval("document.interactiveForm.UCD00" + x + ".value");
bindingGroup = bindingHC + bindingLP + bindingUC + bindingACD + bindingUCD;
reminderImage = eval("document.images.arrow00" + x);
The problem with the script above is that:
1.) Netscape 4.7 does not seem to recognize the eval() method.
2.) The form subits every time it goes through the loop.
Banana Ananda:
Thank you so much. Adding the "valid" variable outside the FOR loop was a good solution to the problem -- with this exception: var valid = false; should read - var valid = true at which point the script works beautifully in current browsers. Unfortunately neither of your suggestions work in NS4. No errors occur, the browser just sits there inert and nothing happens.
Does anyone else have a suggestion how I can access the form fields in NS4?
I don't have an NS4 to test with, but I see absolutely no reason for this not to work. It's all basic stuff.
Which version did you use ?
Are you submitting with a submit button, and using the onsubmit event ?
Does an alert fire if you place it in the top of the function ?
I beg your pardon. I made a false assumption.
Your method for accessing the form elements is working just fine in NS4.
It now appears that NS4 is failing to change the source of my reminder image from a transparent spacer gif to an indicator arrow.
I will have to investigate this further.
Bookmarks