html - how to propagate second drop down menu according to first one? -


my code like. have created 2 pull down menu , have drag second values of second dropdown according first value.

<div>         <label for="program">program</label>         <select id="trigger" name="program" class="x-large">                <option value="1">as</option>             <option value="2">gs</option>                    </select>     </div> <div>         <label for="issuer">award issuer</label>         <select id="issuer" name="issuer">             <option value="1" class="issuer_1">s</option>               <option value="1" class="issuer_1">st</option>         <option value="2" class="issuer_2">skk</option>           </select>     </div> 

use code

    <script> var category = document.getelementbyid('category'); document.getelementbyid('elements').onchange = function() {   var optionselected = this.options[this.selectedindex];   if (optionselected.textcontent != '-') {     if (optionselected.dataset.val === 'm2') {       category.value = 'pm2160a';     }     else if (optionselected.dataset.val === 'm3')  {     category.value='mfm101'; }     else if (optionselected.dataset.val === 'm4')  {     category.value='abc'; }     else {       category.value = 'pm130';     }   } else {     category.value = '';   } } </script> 

html code

<!-------first drop down-----------> <select name="make" id="elements">   <option value="">-</option>   <option value="stace" >stace</option>   <option data-val='m2' value="minibus" >minibus</option>   <option data-val='m3' value="pyrotechnic" >tyro tech</option>    <option data-val='m4' value="schneider" >schneider</option>   <!-- veg --> </select>  <!---------second drop down----------> <select name="model" id="category">   <option value="">-</option>   <option value="pm130" >pm130</option>   <option value="pm2160a" >pm2160a</option>   <option value="mfm101">mfm101</option>    <option value="abc" >abc</option> </select> 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -