*
The moose likes HTML, CSS and JavaScript and the fly likes pre-selecting values in a select list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "pre-selecting values in a select list" Watch "pre-selecting values in a select list" New topic
Author

pre-selecting values in a select list

Priyha Jootu
Ranch Hand

Joined: Sep 13, 2001
Posts: 47
Hi all,
I have 2 pages , say page1.jsp and page2.jsp , i am getting some values from user as input in page1 and after pressing the submit button in page1.jsp, it goes to page2.jsp . In page2.jsp, i am getting these values input by user using a request.getParameter(). page2.jsp has many select lists. Depending on the values the user input in the page1, the select list has to be set to that initial values. For example, there is a select list named "letter type" with values type1 , type2, type3 . If the user selected type2 in the page1, then in page2 the "letter type" select list has to be pre-selected to type2 automatically. Also, I am initialising the "letter type" select list from a javascript file that is included in the page, i mean i dynamically generate the select list.
Can anyone tell me how to pre-select values in the select list. I know if we set the selected property of the option to "selected" it would work, but how to do this based on the user input??
Please let me know how to do this.
Thanks
Priyha
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You would have to get the value of the form passed to the next page via query string of some other method. The you when the javascript is dynamically making the dropdown, then you have to make the selected property true when the values match the information that was passed.
What do exactly want?
Eric
Priyha Jootu
Ranch Hand

Joined: Sep 13, 2001
Posts: 47
Thanks Eric, I did this using the URL search string. This link helped me to do this easily: http://ashutoshsaxena.tripod.com/jstut/tutorials/realjs11.html
Priyha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pre-selecting values in a select list
 
Similar Threads
Assigning String object to bean class reference variable/jsp:usebean issue
Getting the selected drop down value in the next page
variable carryover
Sending the list from server to the JSP
problem using ejb 2.0 stateful session bean