-1
I need, through 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 from my classroom, and some input[type='text']
to bring the data of the selected student, such as "age", "room number", "mother’s name", "father’s name", among others. The page may not have submit as I have more than one <select> </select>
that will play the same role (when selecting an item, it will be displayed in input[type='text']
the characteristics of it). The form that I was able to develop makes it possible to bring the data of one or the other <select> </select>
.
I hope you have understood my problem. I am inexperienced in JS.
Code in PHP:
<?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 system more intuitive, where the user just select and appear in real time for it.
Upshot:
Upon any doubt or observation, I am at your disposal.
the ideal is to try to do, so we can go helping you. If you already have something done, edit and post the code.
– aa_sp
Leave it, I’ll change it.
– Raul Germano