Hi friends,

I have a question regarding the option list in HTML pages....

i have 2 items (class, subclass) each of which have some options and hence i created the drop down lists for the 2 items which when selected by user will go the action page and search for those items in my MySQL db.

Each option of my 1st item (class) has its own 2nd item(subclass). So what i want now is, once the user selects the first item from the list immediately the second item list should only display the respective sub-class items of the selected class item.

I would be really thankful if some one helps me with this.

Thanks in advance.


6 Years
Discussion Span
Last Post by aru211285

the google search
There are many scripts to do just that, there are javascripts to do it clientside if the choices are limited in number
ajax scripts to pull the alternates from a DB table for more complicated data
straight html that refresh the page onchange and _GET a modified page
the one to choose depends on the type of page you are using, and the complexity of the information involved

re: search link; love that animation


<select name="class" id="or" onchange="populate(this)">
<option selected= "yes" name = "Select class">Select class</option>
<option name = "x">x</option>
<option name = "y">y</option>
<option name ="z">z/option>
</select> <br />

I need the option select class to be default and appear always in the drop down list so i gave it <option selected = "yes"> but when i choose a different class (x or y or z) and again refresh the page the drop down list is not changing to "Select class" as its default value and only if i close the browser and open again it works and even in that case the options of "Select class" are not displayed in my second drop down list as default(i used dynamic select box).

Thanks in advance.


<option selected='selected' value=''> Select class</option>
<select name="class" id="or" onchange="populate(other dropdown)"><!-- you cannot repopulate "this" -->
<option selected='selected'value=''>Select class</option>
<option value="x">x</option>
<option value="y">y</option>
<option value="z">z/option>

In your code, the selected option fails, 'yes' is not a valid entry

the code highlighting is given by wrapping the code in [code=html] code here [/code] tags

Edited by almostbob: n/a


HI almostbob,

Thanks for the reply. but for some reason this code doesn't work. It only works if i keep the the populate option as "this" and doesn't really give what i expected (to have the first option always appear in the list everytime i refresh the browser).


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.