Forum Moderators: open

Message Too Old, No Replies

Forms - collecting data

         

Modern Merlin

8:16 am on Dec 28, 2007 (gmt 0)

10+ Year Member



Ok, not sure if there is where I am supposed to put this or not, so allow me to apologize up front if this is supposed to go somewhere else.

I have a page on my client's site that by all technicality has 3 different "forms" on it.

The first form collects a text box, id #, name, and date with of course a submit button. This takes you to another page.

The second "form" is just a button which collects the id # and gets you to another page (not same as the the first form).

The last "form" again is jsut a button that collects the id # and gets you to another page (not same as either before it).

My question is this. On the last two forms, I realized I need the information from the text box, name and date also. Is it possible to pass the information from form1 to form2 and form3 when you click the submit button for either of the last two "forms"?

I hope I am explaining this clearly enough :)

eelixduppy

8:31 am on Dec 28, 2007 (gmt 0)



I would use buttons and javascript to do something like this. Something like the following:

<form method="get" name="aForm">
Name<input type="text" name="name" /><br />
ID<input type="text" name="id" /><br/>
<input type="button" onClick="document.aForm.action = 'one.html'; aForm.submit();" value="One" />
<input type="button" onClick="document.aForm.action = 'two.html'; aForm.submit();" value="Two" />
<input type="button" onClick="document.aForm.action = 'three.html'; aForm.submit();" value="Three" />
</form>

Take notice of the onClick attributes. I set the forms action attribute to where I want to submit the form to and that I call the submit method to actually submit the form.

Modern Merlin

8:39 am on Dec 28, 2007 (gmt 0)

10+ Year Member



Would I have to put anything at the top of the page? I dont know that much about javascript, but any time I have used javascript I have had to add some small snippet of code at the top of the page...

phranque

8:51 am on Dec 28, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you are essentially creating an inline javascript event handler and using standard javascript library functions, so no "script section" is necessary.

Modern Merlin

9:02 am on Dec 28, 2007 (gmt 0)

10+ Year Member



Thanks! Going to go try this now!

Modern Merlin

9:12 am on Dec 28, 2007 (gmt 0)

10+ Year Member



It worked BEAUTIFULLY! THANKS A MILLION! :)