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

How to populate SELECT based on another SELECT

Status
Not open for further replies.

dexthageek

IS-IT--Management
Mar 23, 2002
59
US
I have mulitple FORM SELECTS that are being populated from a mysql database.

I want to populate FORM SELECT 2 based on the OPTION selected from FORM SELECT 1.

If anyone knows how to do this in PHP that would be a great help.

Thanks in Advance.
Mike
 
A script creates an HTML form which includes a SELECT object. The "onchange" attribute of the SELECT object points to JavaScript code which submits the form in which the SELECT object sits. The PHP script to which the form is submitted takes the value selected in the first SELECT object and outputs a form which reproduces the first SELECT and populates the second.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks thats what I started working on yesterday. However with this it will require a refresh of the page. Is there a way to do this without refreshing the page.
 
yes. but not in php. it's a fairly common javascript problem and there are thousands of scripts available to achieve this. you still need php to populate the javascript arrays, of course (unless you are willing to hard code it).

post in the js forum or have a look at javascript.com
 
i have recently noticed that the pear class html_quickform has an extension called _select that does this for you.
 
Thanks QuickForm is an awesome class. However I cant figure out how to tell Quickform what to set my values as it automatically assigns a Number Value to the

Code:
<option value="1"> Assigned by QuickForm

I want quickform to use another value from my database as the value. If anyone has an example of this that they have already written that would be awesome.

Thanks
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top