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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onChange Dropdown Content

Status
Not open for further replies.

jalbao

Programmer
Nov 27, 2000
413
US
I have two drop-down fields - 1) Project 2) Version. Note that each Project will have one or more Versions associated with it.

The values of each drop-down are driven by a database. After the call to the database has been made, the Project drop-down will look similar to this:
Code:
<select name="project">
<option value="1">Proj1
<option value="2">Proj2
<option value="3">Proj3
</select>

Ok, now I need to display the Versions in a drop-down. But, I only want to display the versions that are associated with whatever Project the user has selected.

Can anyone point me in the right direction on how to do this?

It may be worth noting that the functionality I'm looking for is very close to, if not exactly, how those auto sites work where you select your "Make" then you select your "Model".

Thanks
 
There are two ways to do this:[ol][li]Submit the page back to the server when the user selects a project, and then have the page select only those versions from the db and refill the drop-downs.[/li][li]Fill JavaScript array from the initial call to the database, then use JavaScript to re-populate each select box.[/li][/ol]

Which do you prefer?

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Tooled, check the javascript faqs section for dynamic listboxes. That will show you exactly what you're looking for.

-kaht

banghead.gif
 
cLFlaVA - I'd prefer the array method. If I chose the other route, going back to the server, then I'd have to repopulate all the other form fields that the user may have previously filled in.

kaht - thanks, I'll check out the faqs.
 
tooled - if the faq's help, great. otherwise, post back and we'll help.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
There is an ongoing thread about "linked listboxes" or something. Check that out if the FAQ doesn't help.

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakesperean sonnet.
 
chained chessbot, chained.
:)

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
Yes, of course...
:)

--Chessbot

There is a level of Hell reserved for probability theorists in which every monkey that types on a typewriter produces a Shakesperean sonnet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top