I have a select box and the options are auto selected depending on your username which works perfectly however Im struggling to figure out a way to capture the value of the auto selected option.
Currently I have a function for onChange that does this but because the values are being auto set, its obviously bypassing the onChange.
Any ideas?
JSX:
<div class="select">
<select
id="ic"
onChange={(e) =>
incidentCommand(getIncidentCommander(e.target.value))
}
>
<option selected disabled>
Incident Commander
</option>
{getIcUsername == "ayushl" ? (
<option value="ayushl" selected>
Ayush Lal
</option>
) : (
<option value="ayushl">Ayush Lal</option>
)}
{getIcUsername == "BarrieP" ? (
<option value="barriep" selected>
Barrie Pocock
</option>
) : (
<option value="barriep">Barrie Pocock</option>
)}
{getIcUsername == "joeld" ? (
<option value="joeld" selected>
Joel Douglas
</option>
) : (
<option value="joeld">Joel Douglas</option>
)}
{getIcUsername == "NevashR" ? (
<option value="nevashr" selected>
Nevash Reddy
</option>
) : (
<option value="nevashr">Nevash Reddy</option>
)}
{getIcUsername == "SchalkB" ? (
<option value="schalkb" selected>
Schalk Burger
</option>
) : (
<option value="schalkb">Schalk Burger</option>
)}
</select>
</div>
TIA