Skip to main content
December 15, 2009
Answered

Forms: Select options, filtered by another select option

  • December 15, 2009
  • 1 reply
  • 383 views

Hey chaps, hope someone can help with this:

I have a PHP form, with a couple of Select menus, which are populated from two SQL tables:

// Select 1 (main colour):

  1. Red
  2. Blue
  3. Green

// Select 2 (shade colour):

  1. Light Red
  2. Dark Red
  3. Light Blue
  4. Dark Blue
  5. Light Green
  6. Dark Green

What I'm after is something to filter the second select option, after the first select option has been chosen

// Select 1:

  1. Red

// Select 2:

  1. Light Red
  2. Dark Red

I'm pretty sure this is possible, but not sure how to go about it, any help would be most appreciated.

This topic has been closed for replies.
Correct answer David_Powers

What you're referring to are called cascading drop-down menus. You either need to store all the values for the second menu in a JavaScript array, or use Ajax to query the database again, based on the first selection. Do a Google search to find further information.

1 reply

David_Powers
David_PowersCorrect answer
Inspiring
December 16, 2009

What you're referring to are called cascading drop-down menus. You either need to store all the values for the second menu in a JavaScript array, or use Ajax to query the database again, based on the first selection. Do a Google search to find further information.