• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving preselected drop down value

 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 drop down lists, once the user selects the first drop down it gets the list values of second drop down. But i need to save the values selected by the user from the 2 drop down lists when the page reloads and i m thinking of using session. Any help is appreciated.

 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hii divya,
not clear what is happening can you please elaborate it a bit.
thank you.
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are talking about page refresh, then you cannot control that using session on the server unless you use some sort of AJAX to send the currently selected drop down to the server. I had this kind of situation once and I used javascript to store the currently selected drop down as a hash in the URL. in the onLoad event of body tag, I called a method which extracted the value from the hash and pre-selected the drop down.

It goes something like this

 
gurneeraj singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't we use custom tags for this functionality?
 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I want to use sessions to save drop down selected value and i have 2 drop down lists. Any help is appreciated.
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's pretty straight-forward. Save the selection values in the session as scoped variables, then use JSP mechanisms on the page to set the selected attribute on the appropriate <option> elements. What part are you having problems with?
 
divya kundapur
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so i just need to have 2 session.setAttributes for 2 drop down lists, then in the struts action class access them, then how shall i add them in the options tag in jsp , since the inital value is set like this

<option value="0">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you are using Struts, I've moved this to the Struts forum for any further discussion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic