Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript and <SELECT> onchange

Status
Not open for further replies.

carlg

Programmer
Jun 23, 2004
88
US
I have an 2 HTML selects
something like this

<SELECT>
<OPTION>id 1
<OPTION>id 2
<OPTION>id 3
</SELECT>

Then there should be another <SELECT> that only has the options of what is selected by the first select.

For example if the user selects id 2, I want to query the database and make the 2nd select only be valid options for id = 2.


The 2nd select is dependant on what is chosen in 1st select. But 2nd select info will come from database.

How do I do this?

I am using PHP and jscript

Thanks
 
Click the FAQ button on this page and look up the section "dynamic listboxes!" I think there's 3 faqs there that cover this very topic.

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
But what about when the values for the SELECT are coming from the database and not hardcoded in?
 
Since they're coming from the database, that doesn't have a whole lot to do with javascript since it's a client-side language. However, if you want to use AJAX to pull the values dynamically from the database as the first <select> is changed, then you should probably post this question in that forum: forum1600

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top