This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with dropdown box

 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 dropdown boxes. The second box depends on the first one.

The first dropdown box is static and has values to select an option.

The second one is based on the first one and accesses different tables in the database based on the selection.

I am using the Struts html:select tag for the dropdown boxes.

Can somebody give me any hints to code this part?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need javascript.

You can either:
1) Store all tables as javascript collections and dynamically swap out the values of the second menu when the first menu changes.
2) Make a call to the server when the first menu changes to have it return the proper values for the second menu.
 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Can you explain me how should i proceed with the code?
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi meera...

as marc said there were some ways which includes ..

1. store all pertaining data in the javascript variables array
2. get data from the data base based on the data from the first the select option...

Event : onFocusOut("callMyMtd(this)") in first select box.
it will be triggered when when the user clicks and tabs oput from that select box there u have to write

Document.formname.action="kkk\ddd\ddd.do";
documnet.forname.submit();

so above code will call ur pertainig data for second option keep in sesstion or req and show in JSp page using the Tag libs.....

is above enough ...

let me know if i am missing something

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic