I want to have more than 1 form buttons in one of my jsp files. For example 2 submit types called: "Back to Step 1"(input1.jsp) and "Proceed to Step 3" (input3.jsp) in a filed called input2.jsp
I want these to be in the form such that when we click "Back to Step 1" (input1.jsp) we go back one step, however, the data in the input fields on the input1.jsp is still visible, so user can edit the data.
and when after editing fields on input1.jsp the "Proceed to Step 2" (input2.jsp) button is pressed , the input2.jsp page appears, with the data we had entered before going back to input1.jsp still visible, so user can proceed with the form.
Also, i was wondering how can we have more than 2 buttons in logic, as when we declare a form we use method="post" and action="input3.jsp" So it seems only 1 button is supported:s. which i dont want.
But if i use 2 different forms for the two buttons the data on input1.jsp will not be visible in the form on input1.jsp.
Please help. Sorry Im a bit confused here:s Hope I have make myself cleared.
To sucessfully track values through your "wizard"-like forms, all you need to do is create a JavaBean that can hold the values of all the forms you will need to go through, put this bean into the session before you start progressing through the forms, and remove it only when completely done.
Forms can also have multiple submit buttons... you just give each submit button a different "name" value and check for that specific value in the request parameters of whatever resource is specified in the "action" of your form. However, for this to work, you can't specify the next page as the "action"... you really have to use the MVC approach and use a controller servlet. (Or use an MVC framework such as Struts or JSF.)
Thanks! and welcome to the JavaRanch!
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
To show the previous page from the caches (when user submits back button) you can use following JS
[ October 08, 2004: Message edited by: Manoj Gundawar ]
Another solution might be to save yourself the trouble of having to travel to-and-from the server for each of the steps of your wizard...
Instead, consider using the magic of CSS and DHTML to construct each of the panels of the wizard in a separate <div> container that is hidden/shown upon proper validation of the previous panel...
1. Page loads, shows <div id='first'> 2. User fills out form elements in div#first; clicks [next] button 3. [next] button calls a validate/update function that first verifies the data and then hides div#first and shows div#second. 4. continue for as many panels as necessary.
All of the elements are contained in a single form. The last button ([save]) or whatever can then submit the form.
The primary benefit is not having to perform trips to the server just to break the content up into manageable chunks.
Two biggest downsides are: 1) It requires some work to properly deal with which <div> should be shown when the server detects errors in the form data. This isn't impossible, but it's an issue that has to be addressed. 2) If div#third has form element data that is dependent upon the content provided in div#second, this could be tricky. For example, page one selects continent, page two selects country (based on continent), page three selects state or municipality (based on country), etc.
There are 10 types of people in this world...<br />Those who understand binary, and those who don't.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop