• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to retain selected content after post on same page

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Use ajax call to populate your select box .
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 47
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic