Various forms in the same page

We want to make a page in which a form will appear after another first form will be submitted (using this information to fulfill new combos, etc).

The first form had a combo box, but after submitting, the selected option disappear.

How could we "save" the selected option after submitting?

Thanks for all and sorry about my english:)

Rodrigo Santamara, Spain

[397 byte] By [EVA_02] at [2007-9-26 1:19:55]
# 1
It is passed if you submit the form thru post
JavaDen at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
So must i submit the form thru get?
EVA_02 at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
no if you do post and the select box is named LastName you can use this:request.getParameter("LastName");and it should give you the name of the selected item
JavaDen at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

hi eva

so something like this

<form name='frm1' method='post' action=xyz.jsp>

<select name='s1'>

<option>asd</option>

</select>

<input type='submit' value='submit'>

</form>

<form name='frm2' action='xxx.jsp' method ='post'>

other fields

</form>

i think whare you are going wrong is not closing the first form before starting the second.

sandy

sandeep_saluja at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

OK, but after submitting the second form, request changes to fit the new form parameters and no longer has "LastName" as one of their parameters, so request.getParameters("LastName") returns null.

That is why i wanted some type of "static" container to "save" that value before submitting the second form

EVA_02 at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
you can use a hidden field called LastName in the second form and give it the value from the first form
JavaDen at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

hi sandy. It's not exactly that, i've:

<form name='frm1' method='post' action=xyz.jsp>

<select name='s1'>

<option>asd</option>

</select>

<input type='submit' value='submit'>

</form>

<%if(request.getParameter("asd")!=null){%>

<form name='frm2' action='xxx.jsp' method ='post'>

other fields

</form>

>%}%>

First form is a selection of films. I want that the second form only will appear after the film you want to see is selected, showing you the sessions in which that film will be played.

I managed to do it, but the selected film doesn't remain selected when it changes to the second form after submitting the first one

EVA_02 at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

hi eva

i don't know whther you have done a typing mistake or it is real mistake in your program

in your request.getparameter("asd") give the select name...

otherwise it will return null.

also if this is not the problem please explain it more as i am not able to get the eaxct problem you are facing.

sandy

or mail me detail at

sandeep_saluja@yahoo.com

sandeep_saluja at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

Sorry it was a typing mistake :)

This point is correct in my code.

What i mean is that, during execution of the code, i select a film in the select box of first form (i.e Gladiator) and Gladiator keeps as the option selected in the box. When i submit this first form, the second form appears under the first one, with sessions for Gladiator (what i wanted) but Gladiator fades as the option selected in the box (i mean, it continues selected, but the combo in the interface doesn't show it as the option selected, instead putting the first option as if there werent' nothin selected)

thanks sandy for trying to understand my poors explanations :)

EVA_02 at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

got it do the following

after submitting the form use this code in jsp .The jsp to which the form gets submitted

code:

<form name='frm1' method='post' action=xyz.jsp>

<select name='s1'>

<%if(request.getParameter("s1")!=null){%>

<option><%= request.getParameter("s1") %></option> //this will show gladiator as selected and first film

>%}%>

<option>other films</option> //otherfilms

</select>

<input type='submit' value='submit'>

</form>

<%if(request.getParameter("s1")!=null){%>

<form name='frm2' action='xxx.jsp' method ='post'>

other fields

</form>

>%}%>

bye

sandy

no need to say thanks we are here to help each other. sorry but i got to log off now if any other query mail me

sandeep_saluja@yahoo.com

sandeep_saluja at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 11

you have to check the select box

like

<%

String asd = "s2";

String selected ="selected";

%>

<select name='s1'>

<option >s1</option>

<option ><%if(asd=="s2"){%>selected<%}%>>s2</option>

</select>

JavaDen at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 12

you can use this you need the selected inside the option for it to be selected

<form name='frm1' method='post' action=xyz.jsp>

<select name='s1'>

<%if(request.getParameter("s1")!=null){%>

<option selected><%= request.getParameter("s1") %></option> //this will show gladiator as selected and first film

>%}%>

<option>other films</option> //otherfilms

</select>

<input type='submit' value='submit'>

</form>

JavaDen at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 13

Hi EVA,

I found an error in your code:

<form name='frm1' method='post' action=xyz.jsp>

<select name='s1'>

<option>asd</option>

</select>

<input type='submit' value='submit'>

</form>

<%if(request.getParameter("asd")!=null){%>

<form name='frm2' action='xxx.jsp' method ='post'>

other fields

</form>

>%}%>

when you are checking for not equal to null condition you are directly using "request.getParameter("asd")" where 'asd' is not a form parameter..Use, request.getParameter("s1")..

Gsunfun at 2007-6-29 0:53:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...