PDA

View Full Version : Counting number of forms an any given page


JSB
09-26-2002, 04:50 AM
New guy here.

I'm working on a script that will simply take the numher of forms on any page and then loop through disabling the submit and view buttons.

I wrote a (well would like to write) a function that I can call within the functions I currently have to disable the buttons.
All my script works separtely but not together.

When I add the following, it gives me "is null or is not an object".

function disbuttons(){
numForms = document.forms.length;
for (x=0;x<numForms;x++){
document.forms[x].mySubmit.disabled = true;
document.forms[x].myView.disabled = true;
}
}

Please help. I'm the kind of person that won't ask unless I have tried everything I know to try and then some.

Thanks.

JSB
09-26-2002, 05:57 AM
I did several searches before posting this question.
Please?

adios
09-26-2002, 06:39 AM
JSB

What you posted looks fine. Could we see more?

JSB
09-26-2002, 08:39 AM
This is the entire script.
With the instance that I'm working with, there are two forms on the page. Each form has two buttons, both of them with the names mySubmit and myView but with different form names.

The order appearance on this page is the form EditorSurvey and thusly, form[0]. The second form is bPoll and thusly, form[1].

Form[0]'s buttons are mySubmit which onclick calls the function checkradios(), and myView which onclick calls the function viewresultsEdsurvey().

Form[1]'s buttons are mySubmit which onclick calls the function buildpoll() and myView which onclick calls the function viewbpoll().

function doBuildPoll() and function dbuttons() (which is not shown here) are not used on this page. They are used when and if the user wants to see the results of the survey and the inputs calling these functions are written or left out by way of ASP code.

In any case, isolated trials have not shown any different results.
I have taken the resulting HTML and script shown below into a seperate test page to try and isolate the problem.

SCRIPT...

I can't believe that all along it was only a case of CaSe !
I apologize if anyone read through the script that I had posted here earlier. Hopefully, at least, you got a good laugh.

The problem was that my calls to the function in question were "disButtons()" but the function itself was entered as "disbuttons()". A simple case of CASE.

I'm not a javascripter by any means and I sometimes forget that JS is case SenSiTIve.

Damn it!
Once again, sorry about this sTuPid p0st.