View Full Version : Changing number of fields in a form?

11-05-2002, 06:35 PM
Everyone and anyone. I'm not a programmer so please forgive the crap way I have achieved this so far....

I'm currently working on a "spot the ball" page for a friend and have a working script that will enable you to have 5 seperate guesses which in turn will return the x and y coordinates of each guess to a form

see www.stenicol.com

to see the php code goto www.stenicol.com/test (I have renamed the files to a .phps format)

What I would like to do is instead of having 5 guesses by default is to have the option of being asked how many guesses you would like to enter, and then depending on the answer, updating the form automatically to indicate the relevant number of guesses.

I'm sure this will involve completelt re-writing the whole setup but haven't a clue how to accomplish it.

Can anyone throw so light my way?

11-05-2002, 09:22 PM
Why don't you let PHP do the walking on this one? First page, prompt the user for the number of guesses they would like, then use that value (you could register it as part of the session) to create the appropriate number of elements on the form page. MUCH better than any javascript solution (although it CAN be done with JS)

11-05-2002, 10:37 PM
A JS solution would be something along the lines of dynamically changing the element.style.display value from none to inline or the element.style.visibility value from hidden to visible -- not all that tough.

Unfortunately, I don't have the time to write up the code right now ...