I am trying to achieve something like this,
<select id="time" size="1" name="Time" disabled="disabled">
<% foreach (string item in (List<string>)Model.OpenCloseTime[dynamicVariable].AppointmentTimes)
{%>
<option id="<%:item%>" value="<%:item%>">
<%:item%></option>
<%}
%>
</select>
Where dynamicVariable= $('#date').datepicker("getDate");
To break down the issue, getDate is supposed to fetch the value of the weekday from a calendar which needs to help me dynamically populate a select dropdown, based on the data we are getting from the model object day value.
How could I achieve this?
Thanks for the help.
I’m not sure what
dynamicVariablelooks like, but here’s how you can populate#timewith a Javascript array:Edit to answer your comment:
Concatenate your list:
Print it in your javascript:
Explode the string into a Javascript array:
Use what I posted above to make the select box: