Getting Parameters from form

Hi, I am trying to use a HTML form which has a drop down list, where a user selects an entry and the entry gets displayed on the same page when the user presses a 'submit' button. I have managed to do this, but I keep getting a value displayed on the screen before the submit button gets pressed, i.e. a entry appears on the screen when the page first loads! I am not sure why this is - I may need to initialise some variable as blank, but I am not sure which one! A snippet of my code is given below where a user is asked to select an entry froma drop down list (an application name), then the 'request' object gets the parameters, where I display the 'parameterValue' variable on the screen. This is the variable that I am trying to get blank before the user submits. <TD> Please Choose An Application from the Drop down menu</TD> <TD> <SELECT NAME=App> <%int k=0; while(appnames[k]!=null){%> <OPTION><%=appnames[k]%></OPTION> <%k++;}%> </SELECT></TD> <INPUT TYPE=SUBMIT VALUE=Submit> <% Enumeration parameters = request.getParameterNames(); while(parameters.hasMoreElements()){ parameterName = (String)parameters.nextElement(); parameterValue = request.getParameter(parameterName); %> <TD><%=parameterValue%></TD>

All desirable things in life are either illegal, banned, expensive or married to someone else !!!

Kamal Patel
Greenhorn

Joined: Nov 05, 2003
Posts: 18

posted Nov 10, 2003 08:49:00

0

Just tried putting the ------select------- entry in, but has not made a difference - still picking up a value. It is like it is caching a value that I selected before I refresh the page! I think I need some way of saying, don't call the: Enumeration parameters = request.getParameterNames(); code when the page first loads??

Basically you did not make all your code available and people are responding based on partial information. I think you are submitting to the same form which makes the parameter value always available to the request. Please paste the whole code including the form tag so people would have enough information to help you out. We might even run the application to know how to tackle the problem. [ November 10, 2003: Message edited by: Anselm Paulinus ]

Hey Kamal, It is working fine for me!!! I have pasted your code in my file and tried with few changes Change 1 - As I the combo box shows me only ---select value----- I have added <option>--slect valeu1</option> <option>--slect valeu2</option> <option>--slect valeu3</option> then i open new browser and executed this file the list line of o/p is Application Selected Then I select first option and hit submit last two lines of o/p Application selected -------Select Value1-------

then i reopne the browser and type same url with gives me nothing after Application Selectd so i Think there is problem with your browser,try with deleting all offline contents. Cheers Praful SORRY FOR LOT OF MISS-SPELLS was in hurry to go home [ November 10, 2003: Message edited by: Praful Thakare ]

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com