Click to See Complete Forum and Search --> : Verifying dynamic Javascript forms


LookitsPuck
April 29th, 2004, 03:17 PM
Okay, on my main page [for a class], I have the page broken into different divisions in CSS. Each division has their own forms [except for the show movie reviews feature]. Now, the first one [update] has checkboxes and a text box. The text box takes in the movie id and then the user clicks their desired checkboxes [i.e. which values they'd like to change].

The data is then sent to a php page and based upon whether or not the variables were set, the form types print out. For example, if the user clicked Movie Title, Movie Rating, then on the next page 2 text boxes would be on there instead of all of the different Movie attributes. I then need to validate the data entered into the boxes. How would I go about doing this since the page is updated based upon how many checkboxes are checked?

On my main page I have Javascript verification, so I know how to do it. I just don't know how to do it with a page that dynamically changes the number of text boxes on the page.

Thanks all!
-Steve

LookitsPuck
April 30th, 2004, 11:18 AM
After a little testing and what not, I've got it working! Turns out, that you can do a conditional test to determine whether or not a type of form [text box for example] has been loaded into a page by simply doing the following:

if (document.nameofform.nameofformobject)
do something

So if you had a form named update and your form object was a textbox named title, you can test to see if it was loaded into the page by using the conditional:

if (document.update.title)
do something

This works for what I was working with because I have a page that dynamically loads form types based upon what was clicked on the page before. If 3 things were clicked, 3 types of text boxes would show up and only those 3 would have to be validated.

Alrighty,
-Steve