2
I made a built-in autocomplete in a field input
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 attribute value
.
I would like to complete the input
guy text
with the Name of the Person, but did not want to lose the ID
when sending the form.
I thought I’d try to assign the value of ID's
in a field of the kind hidden
, but I don’t know how to assign the value when there is selection in datalist
.
I added an answer just below, so I understand you wanted to send the
id
and select the name ofProfessor
– Marconi
Erick I made a few edits that I think is pertinent, in case you do not inform me that I return as before, welcome to Stackoverflow, I recommend reading on tour to understand a little more about how things work around here.
– Marconi
Thank you so much for your contribution! I made the implementation according to your guidance and solved my problem.
– Eric Coutinho