2
I have a code that selects an option of the data coming from the database. This part of the code is ok, it selects and brings.
The problem is that by selecting this option
, need to fill 4 fields input
automatically, with data coming from the database.
I can only show a data. I believe I have to store this data to use in inputs
, but I don’t know how to.
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>
Gabriel, in case I need to go through an array to check which fields and show them. For example, I have in the database the column A B C and in each column of these I have data type, serial tag. If I select option B it should show in the input type, tag and series. If it is option A, same thing.
– user132928