I made a coupled autocomplete in a input
field without much difficulty, as shown below:
<label>Professor</label>
<input type="text" list="list-professor" name="professor_id">
<datalist id="list-professor">
<select>
<option value="1">Roberto</option>
<option value="2">Rosana</option>
<option value="3">Romualdo</option>
</select>
</datalist>
The datalist
always returns the value contained in the value
attribute.
I would like to autocomplete input
type text
with Person Name, but did not want to lose ID
when submitting the form.
I thought of trying to assign the value of ID's
to a field of type hidden
, but I do not know how to assign the value when there is selection in datalist
.