Solved

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

Posted on 2003-12-03
8
420 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
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now