How to depend two <select> items on each other in Javascript

Hi there

This is my jsfiddle.net
http://jsfiddle.net/vngx/099qnwkb/1/

What I want that if some value is select from one group then another set of drop-down should change relative to first.

How could I acheive this?
(I don’t know whethar I should post this question on JavaScript or HTML.But I have posted it here)

Thanks

This would need to be Javascript. I have moved it for you along with renaming your thread title.

Here is a VERY basic example of what you’re looking for.

http://www.javascripttoolbox.com/lib/dynamicoptionlist/

This can be done as above, with pure JavaScript; you can also bring a server-side possibility and have the first select onchange get data from a database via AJaX and populate the second select with that.

There are many possibilities.

HTH,

:slight_smile:

@Wolfshade

Thanks this is exactly I am looking for How could I add this on a Particular page on a long HTML page?

If you want to do a pure vanilla JavaScript method (ie, no jQuery or MooTools, no library, no framework), you would take that <script> and place it at the bottom of the page, before the closing </body> tag, modify it to what you need as far as what options appear in the selects, download the dynamicoptionlist.js file and place it wherever you are placing your .js files, put <script src="/path/to/js/dynamicoptionlist.js"></script> inside your <head></head> tags, give the <body> tag the onload attribute “initDynamicOptionLists()”, and basically follow the instructions listed on this page.

HTH,

:slight_smile:

Thanks for reply

can you add some code snipshot in this

Here is my version with jQuery only: http://jsfiddle.net/w4ref01n/

@megazoid:

This is cool.exactly I am looking for

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.