Solved

how to populate a select box which is dependent on another select box

Posted on 2003-12-03
8
428 Views
Last Modified: 2008-03-10
hi,
i need to populate a select box with values from database. but this should be done based on the value selected in the other select box.

for example,
selectbox1 contains options like:
hardware
software

if hardware is selected, selectbox2 must have the following options(got from the database)
PC
UPS
PRINTERS

could you tell me how to implements it by using action, actionform and jsp

help me regarding this.
0
Comment
Question by:cheungyipyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 48 total points
ID: 9865472
Well here is what you will have to do....
First show the form with first select box shown...

<SELECT NAME="SELECTFIELD"  onblur=" submitthis();">
<OPTION VALUE="Hardware">Hardware</OPTION>
<OPTION VALUE="Software">Software</OPTION></SELECT>

<SELECT name="other>
<%
qry=select value from table2 where key=request.getParameter("SELECTFIELD");
rs=stmt.executeQuery(qry);
while (rs.next())
{%>
<OPTION value=<%=rs.getString(1) ><%=rs.getString(1)%.</OPTION>
<%}%>



and submitthis() function will just submit the form back to jsp....
Ofcourse you will have to put some if conditions here and there to control the execution of this query only after submission of the page.. But I am just trying to give a outline here.
Hope this helps


0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 46 total points
ID: 9867582
0
 

Author Comment

by:cheungyipyan
ID: 9873230
Thank for reply!!
but i need a sample that implements by using Struts
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Assisted Solution

by:u9707118
u9707118 earned 46 total points
ID: 9874071
Check out 'Dependent Drop Down Combo Box Lists' on page 7

http://stealthis.athensgroup.com/presentations/Model_Layer_Framework/Struts_Whitepaper.pdf

Hope this helps,

Damian
0
 

Author Comment

by:cheungyipyan
ID: 9874179
Thank you for all replies
However, i really want to know how to write the codes of JSP, Action and ActionForm to achieve my goal.

Please help me......................
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9874917
It's difficult for us to teach you how to use structs in a forum thread, it's just too much.
I think you much pick up struts yourself, then it is trivial task to translate the given sample to struts with your particular needs.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question