This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain selected content after post on same page

 
chetan sisodiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geeks,

I m very new to JSP and java script.
I have a 2 dropdown list. In both drop down i m fetching some data from data base.
In SECOND DROPDOWN LIST I have to fetch data depending on the selected item of the SECOND DropDOwn list. I have succeeded in that.

PROBLEM :
But when I select an item in first dropdown list, i m posting fors data to jsp code,and proper resuld are reflecting back. But on every ONCHANGE event on my first dropdown list page is getting reloaded and the FIRST DROPDOWN list data is get emptied. I mean it should contain what I have selected after posting parameter to jsp.
How can I stop from this or how can i retain value in the dropdown list. Is should get set back to default....
 
Miku Ranjan
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Use ajax call to populate your select box .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly. "Cascading dropdowns" has become almost a poster child for Ajax.

If the idea of Ajax scares you, then adopting a library such as jQuery makes it a single line of script. If this direction intrigues you, I can point you to free downloadable examples from my jQuery book.
 
himanshu.harish agrawal
Ranch Hand
Posts: 47
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before heading towards big daddies like Ajax and jQuery, try visiting . I think you get you solution.

Regards,
Himanshu
 
chetan sisodiya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

posted Today 1:49:17 PM 0
uday singh rajpurohit wrote:
Thanks Himanshu


Himanshu, the link you gave is I m familior with already. My problem is that I am not senting parameter to a diff page. I m posting dropdown's parameter on the same page. and on eveny ONCHANGE event on the first dropdown list proper result are reflectiung back on second parameter but the value of second drop down is set set back to default selected calue.. Is should be what I selected before.



Can any once plese send the code to populate the value in drodown list after submitting form.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic