File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Drop Down Box values can be retained

 
Dinesh Remje
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the code i have written in JSP and is working fine when javascript is turned on.
Now i have done Java validation also. Now it work perfectly fine showing the error. The only thing i need here is that i want to retain the value which will be selected by user when javascript is turned off.
I am able to retain the value when javascript is on. So how can i do that.
Following is the code which i have written


There are in all 10 values with their respective values so how can i do that. Please help me. How can i retain the selected value even after the form is refreshed.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I understand is, you want to display the selected value for list.

you can use the selected attribute of the option tag, and display the selected option based on what user has selected.

When form is submitted, you can check for the selected designation and based on that put selected on an option


 
Dinesh Remje
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i want to retain value that will be selected by user.
Right now i m able to retain the "Select Designation" value as i have set it.
But i need to retain value that will be selected by the user from the list i.e HOD, Assistant Professor etc
 
amit punekar
Ranch Hand
Posts: 544
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
You have to put the selected value in the HttpSession.
And while rendering the screen again , within that JSP add the SELECTED attribute to it based on the match between session value and the one of the values in the dropdown.

Regards,
amit
 
Dinesh Remje
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Amit,

Ya was able to do it.
What i have done is stored all the values in an 2D array and called those value in for loop and in if condition i checked whether that value is selected.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic