Solved

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

Posted on 2003-12-03
8
421 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

930 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

14 Experts available now in Live!

Get 1:1 Help Now