<div class="form-dropdown">
<select value="" aria-labelledby="timeWindows_label" aria-invalid="false" aria-required="true" aria-describedby="timeslot-error" class=" form-dropdown-select" id="timeWindows">
<option value="8-12:30-12:45">12:30 – 12:45</option>
<option value="8-12:45-13:00">12:45 – 13:00</option>
<option value="8-13:00-13:15">13:00 – 13:15</option>
I would like to select the option by js, but it failed.
I used document.getElementById('timeWindows').value = '8-12:30-12:45', it returns error (timeslot is not selected)
I also used document.getElementById('timeWindows')[1].selected = true, it's still the same.
The displayed option has been changed, but the code returns error and nothing changed.
The errored code is below
<div class=" is-error form-dropdown">
<select value="" aria-labelledby="timeWindows_label" aria-invalid="true" aria-required="true" aria-describedby="timeslot-error" class=" form-dropdown-select" id="timeWindows">
<option value="8-12:30-12:45">12:30 – 12:45</option>
<option value="8-12:45-13:00">12:45 – 13:00</option>
<option value="8-13:00-13:15">13:00 – 13:15</option>
This is the successful example when I use the mouse to click the option.
<div class="form-dropdown">
<select value="8-12:45-13:00" aria-labelledby="timeWindows_label" aria-invalid="false" aria-required="true" aria-describedby="timeslot-error" class=" form-dropdown-select" id="timeWindows">
<option value="8-12:30-12:45">12:30 – 12:45</option>
<option value="8-12:45-13:00" selected="true">12:45 – 13:00</option>
<option value="8-13:00-13:15">13:00 – 13:15</option>
I also found the timeslot error in the source, but I don't know what the code refers to.
"timeSlotNotSelectedError":{"microEvents":[{"key":"eVar25","value":"transaction.co.fulfillment.timeslot.error.timeslot_not_selected","slot":"Pickup"}]},