Jump to content

Run query to populate a drop-down based on onchange value of previous drop-down


monkey64

Recommended Posts

I do know that I can't use PHP with the onchange event as it's a Server Side language, not Client side like Javascript.  I used the onchange event to describe what I want to do.  Here we go!

 

I have two drop-down boxes on my form which are populated dynamically from my database.

 

Here's what I want to:

 

1. Pre-populate the first drop-down box from the database.

2. Make a selection.

3. When the onchange event occurs, populate the second drop-down box with a query based on the value from first one.

 

There's a good example here: http://www.eurocarparts.com If you select a manufacturer, and click the button, the next drop-down gives you values only relevant to that manufacturer. It's really smart.

 

Is it even possible using PHP?

 

Any help would be appreciated

its actually refreshing the whole page based upon a posted value for the new query to be run

when you select a manufacturer and select go, it posts it back to itself a value for the next drop down

 

such as you select "honda" and push go ->($_POST['manu'])

 

if(isset($_POST['manu']))

{

manu = $_POST['manu'];

$query = "SELECT * FROM subheadings WHERE manufacturer = 'manu'";

*****code for making second drop down*****

}

 

and so on a so forth until all relevant drop downs are created

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.