0
Good evening guys, I have the following code on a hotel system I’m setting up:
<?php
include "Hospede.php";
$newHospede = new Hospede();
$rs = $newHospede->listarNomesHospedes();
$qtdHospedes = mysql_num_rows ($rs);
?>
<input list="hospedes" name="hospede" id="hospede" required>
<datalist id="hospedes">
<?php
for ($cont = 0; $cont < $qtdHospedes; $cont++){
$nome = mysql_result ($rs, $cont, "nome");
?>
<option value="<?php echo $nome; ?>">
<?php
}
?>
</datalist>
The guest camp has a list of the names of the guests that the query in the database returned, but I’m having a problem: due to the fact that the datalist type field allows the user to type in to search for an item from the list, It is possible for the user to type anything and submit the form, since the "required" attribute of the HTML lets go only by the fact that the user has typed something inside the field. I need to find a way to force the user to select an item from the list. If you can help, thank you.
I managed to do what you asked
– user60252
"the way to put in this vector palavrasAceitas all the names that the query in the database returned". I edited the answer, is at the end in Bonus.
– user60252
I see myself man, tomorrow I will test.
– Leandro