I need to, with a <select> </select>
, bring the data to some input[type='text']
. I believe it is through JSON and AJAX, because the page can not have any "Submit".
For example:
I have a <select> </select>
to select a student in my classroom, and some input[type='text']
to bring the data of the selected student, such as " age ", " room number "," parent name "," parent name ", and more. The page can not have Submit because I have more than <select> </select>
that will do the same role (when selecting an item, it will be displayed in input[type='text']
its characteristics). The form that I was able to develop allows to bring the data of one or the other <select> </select>
.
I hope you have understood my problem. I'm inexperienced in JS.
PHP code:
<?php $query="SELECT idFunc AS 'ID', nomeFunc AS 'NOME', idadeFunc AS 'IDADE' FROM funcionario WHERE statusFunc = '1' ORDER BY nomeFunc"; ?>
<form method="GET" action="">
<select name="aluno" onclick="if (this.value != ''){this.form.submit()};">
<option value="">- ALUNOS -</option>
<?php $sql = odbc_exec($con, $query);
$i=0;
while(odbc_fetch_row($sql)){
$id=odbc_result($sql,"ID");
$nome=odbc_result($sql,"NOME");
$idade=odbc_result($sql,"IDADE");
$i++;
?>
<option value="<?php echo $id; ?>" ><?php echo $nome; ?></option>
<?php
} odbc_close($con);
?>
</select>
</form>
In PHP, I was able to do what I wanted, but when I select another checkbox, it deletes the first result and displays the results of the second. I could make the user select the two items and after doing a Submit, the information would appear, but I want to make a more intuitive system, in which the user just select and appear in real time for him.
Result:
About any questions or comments, I am at your disposal.