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);