Jump to content

Drop Down Lists


SunTzu
 Share

Recommended Posts

Hi to All,I have spent whole day trying to figure out how to populate a drop down list according to the value of another drop down list.I have "departments" and "positions" so when i select a dept. from the first drop down i want the respective positions to populate the other. The problem here is that i need to do that before "Posting" the form which would resolve easily my problem.I tried to use JavaScript but in vain as JS is used at the client side while PhP at the server side.Please advise ...thnx

Link to comment
Share on other sites

One thing you need to understand is that php is a server side script. It will not do anything unless the user (read: the function a user is using) is making a request.What you can do is have the user select a department, have that saved to a session (or propagate it) when the user hits 'next' and perform a query on the db to select all positions where department = $department. The result will be 'looped' into a new dropdown.A combo of js and iframes is a realistic one too, but you're going to find iframes is a world of hurt on itself.There's more solutions available on the web. They're not easy (and usually require client sided scripting) but they're well worth the effort.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...