I have a code that selects an option from the data that comes from the database. This part of the code is ok, it selects and brings.
The problem is that when I select this option
, I need to populate 4 fields input
automatically, with data coming from the database.
I can only show one die. I think I have to save this data to use in inputs
, but I do not know how to do it.
I will post the code below commenting:
<?php
require_once('requerimentoController.class.php');
$requerimento = new requerimentoController;
$acervoGrid = $requerimento->gridAcervos();//Aqui recebo os dados do BD
$qtdRow = count($acervoGrid);
?>
<html>
<script>
function selecionar(){
document.getElementById('tipo').value = document.getElementById('selectOK').value;
}
</script>
<body>
<select id="selectOK" onchange="selecionar()">
<?php for($a = '0'; $a < $qtdRow; $a++){ ?>
<option value="<?=$acervoGrid[$a]['tipo'];?>"><?php echo $acervoGrid[$a]['tipo']; ?>
/* Aqui seleciono qual o valor que quero da tabela*/
<?php }?>
</select></br>
<input type="text" id="tipo"/> /*aqui mostro no input os valores correspondentes ao que selecionei no option com dados que vem do banco.
<input type="text" id="marca"/>
<input type="text" id="serie"/>
<input type="text" id="modelo"/>
</body>
</html>