• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select box get refresh after populating the data into a table.

 
kaushal sharma
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,


Need help.

i have a select box in which the data is populated from database. When i select an option in select box, the relevant data is populated in a table on the same page but the selected option in the select box get refresh and show me the "Select Option" the first value.
I need to know how can i make the selected option visible in the select box after selecting one.


-Thanks & Regards,
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't mention which version of Struts you are using. Suppose your select tag looks like this


Now if your action looks like this (Struts 2)

Now it will work, the select box will be rendered using the catList list, then if you submit the page, the selected value will go into the category named String. And then when the page will be generated again, the option whose value matches the value of category string, that value will be selected. Remember that you can define a different property to preselect a value using the value attribute of the select tag...
 
kaushal sharma
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

Thanks for your suggestions. Sending you my code.




hope now you can suggest me more appropriate.

-Thanks & Regards,
Kaushal K. Sharma
 
kaushal sharma
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Expecting a suggestion. Kindly provide some docs or code to do this.



-Thanks & Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic