$('a#noday').click(function()
{ for(g=1;g<=10;g++)
var ddl = document.getElementById('daySelect_'+g);
var opts = ddl.options.length;
for (var i=0; i<opts; i++){
if (ddl.options[i].value == ""){
ddl.options[i].selected = true;
break;
}
})
$('a#wed').click(function()
{ for(g=1;g<=10;g++)
var ddl = document.getElementById('daySelect_'+g);
var opts = ddl.options.length;
for (var i=0; i<opts; i++){
if (ddl.options[i].value == "wed"){
ddl.options[i].selected = true;
break;
}
})
Below is my select html code
<select class="form-control daySelect" id="daySelect_1" name="daySelect_1">
<option value="">Select</option>
<option value="wed">Wed</option>
<option value="sat">Sat</option>
<option value="sun">Sun</option>
<option value="satsun">Sat/Sun</option>
<option value="wedsatsun">WedSatSun</option>
</select>
Below is my hyperlink html
Set all to:
<a id="noday" href="#"><span class="label label-info">No Day</span></a>
<a id="wed" href="#"><span class="label label-info">Wednesday</span></a>
I tried to click the hyperlink, but my dropdownlist selected does not change. I did try the alert to make sure my link work, and it manage to execute alert.
My JsFiddle
$('#wed')instead of$('a#wed')? Because the id must be always unique on the page.