Jump to content


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


Dropdown menu changes options in another

Recommended Posts


I've been looking around and I can not seem to find a simple enough example of what I want to do with javascript and drop down menus.

With my first <select> I generate the menu from a PHP array (string and string)

depending on what item the user clicks on I want it to populate a corrisponding <select> with another array that is set using PHP

I could probally do this with $_GET after selecting the first option, but I would rather have it load the 2nd <select> without reloading the page. There are other form elements that I dont want the user to have to re-enter :)

Why does this seems harder than I thought it would?

Would I use the OnChange option for the <select> then pass the value of the selectedindex? I am thing unsure how would I go about having javascrip update the 2nd <select> by populating it with one of the indexes from a multidimention array based on the first <select>

Hopefully that makes sense.

Share this post

Link to post
Share on other sites

Since PHP is serverside, it cant tell what varible is selected in the javascript. I saw an suggestion to use the DOM and have javascript request something from the server, but thats too much work for what I am trying to do...


Share this post

Link to post
Share on other sites


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.