Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
How to use mouse to click/select the option?
<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"}]},
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Check this jsfiddle: https://jsfiddle.net/zhuhang95/wjgra9fL/3/

Your code is working fine in jsFiddle. Make sure you use this method to change the option:

document.getElementById('timeWindows').selectedIndex = 0;

If your code looks exactly same, but you still get the error, then the problem is somewhere else in your code.

More info on how to select option using JS: https://stackoverflow.com/a/7373115/6122411

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!