How to populate datepicker and dropdown menu on selection of another dropdown..?

I was trying to populate datepicker as well as drop down menu as soon user selects one of the option from another dropdown menu…But it’s not working…

Below is my html code

     <div id="wrapper">
       <select id="select" name="options">
        <option>Select The Value</option>
        <option id="hourly" value="a">Hourly</option>
        <option id="daily" value="b">Daily</option>
        <option id="monthly" value="c">Monthly</option>
        <option id="yearly" value="d">Yearly</option> 
       </select><br/>
     </div>

Below is javascript code:

    var select=document.getElementById('select');
    var wrappElement=document.getElementById('wrapper');
  
   select.addEventListener('change',function(){
 if(select.value=='a'){
 var dateElement=document.createElement('input');
 dateElement.type='date';  
 wrappElement.appendChild(dateElement);
 var arr = ["1","2","3","4","5"];
 for(var i=0;i<= arr.length;i++)
 {
    var value = arr[i];
    var drop = document.createElement("option");
    drop.textContent = value;
    wrappElement.appendChild(drop);
 }
 }
} , false);

How is it not working?

@Dormilich…its not populating the fields upon selection of the value…
below is the jsfiddle link its not generating dropdown menu.::sweat:

works perfectly fine, once you uncomment the code.

@Dormilich…thats not the fiddle …
below is the link…

That is the same I tested in the previous response.

thats not the code…

below is the link…

it doesn’t make a lot of sense adding <option>s to a <div>, does it?

yup…

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