I am trying to use JS to update the selected value of multiple select
elements, at the same time. For some reason, my JS only updates one select
, not all of them on the page. Unfortunately, I am not able to change the id
attribute of the select
, and the various select
elements need to have the same id
.
How might I change the function so that ALL drop downs with id 'dropdown-test' are updated?
JS
document.getElementById('dropdown-test').value="3";
HTML
<select id="dropdown_test">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<select id="dropdown_test">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>