Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Drop-down" selected value not updated in HTML

When I select a new value (3) in a drop down menu, I see that HTML still has the old value (10) as "selected".

<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10" selected="selected">10</option>

EDIT 1: the problem manifests itself when I clone the form. The cloned copy has its selected option reset. Is there a way to clone the selected value too?

like image 908
jazzblue Avatar asked Jul 12 '26 12:07

jazzblue


1 Answers

The reason you are seeing this is that changing the selected index will not alter the attribute on the html element itself. However, the value actually is changed.

See this demo for an example of what the selected index shows when changed

like image 117
Travis J Avatar answered Jul 14 '26 02:07

Travis J