Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.