javascript - Add select box based on value in other select box -


i have select box on web page, when selct value should add other select box , if select value on second select box need add third select box here code

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js">    </script> <script type="text/javascript"      src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.js">   </script> <link rel="stylesheet" type="text/css" href="/css/normalize.css"> <link rel="stylesheet" type="text/css" href="/css/result-light.css"> <style type="text/css"> </style> <script type="text/javascript">//<![cdata[   $(function() {         $('#colorselector').change(function(){             $('.colors').hide();            $('#' + $(this).val()).show();       });    }); //]]>   </script> </head> <body> <select id="colorselector"> <option value="red">red</option> <option value="yellow">yellow</option>  </select> <div id="red" class="colors" style="display:none"> <select id="colorselector"> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> </select>  </div> <div id="yellow" class="colors" style="display:none">  <select id="colorselector"> <option value="one">one</option>  <option value="two">two</option>  <option value="three">three</option>  </select>   </div>   <div id="one" class="colors" style="display:none"> one... </div> <div id="two" class="colors" style="display:none">  <select id="colorselector"> <option value="one">four</option> <option value="two">five</option> <option value="three">six</option> </select>   </div> </body> </html> 

i got second select box, cant able add third 1 based on select select box value

as has said above, ids must unique.

use:

yellow > 2 

http://jsfiddle.net/psyat5s8/


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -