0
I cannot recover the recorded value of select
.
I have this recovery by input
that is working normally.
<td>
<div class="drop-down-select opcoes ">
<label for="bairro">Bairro:</label>
<input type="text" size="50" class="form-control" id="bairro" name="bairro" value = "<?php echo $bairro;?>" >
</div>
</td>
<td>
<div class="drop-down-select opcoes ">
<label for="rua">Rua:</label>
<input type="text" size="70" class="form-control" id="rua" name="rua" value = "<?php echo $rua;?>" >
</div>
</td>
But if possible, wanted to recover this data by Select, follow the code below...
<td width="160">
<div class="drop-down-select opcoes ">
<label for="bairro">Bairro:</label>
<select name="bairro" id="bairro" required>
<option value="">Selecione</option>
<?php foreach ($bairros as $bairro) { ?>
<option value="<?php echo $bairro['id'] ?>"><?php echo $bairro['nome'] ?></option>
<?php } ?>
</select>
</div>
</td>
<td>
<div class="drop-down-select opcoes ">
<label for="rua">Rua:</label>
<select name="rua" id="rua" disabled required>
<option value="<?php $rua; ?>">Selecione uma Rua</option>
</select>
</div>
</td>
This is the same dynamic select I use for registration. Thank you in advance.
It hasn’t worked out yet. Added this... $("#neighborhood ::Selected"). text(); ... ... ... The correct neighborhood appeared, but the street did not appear, like, to appear on the street, I would have to select another neighborhood that did not belong to the information update. In the street option, it said that the value was undefined. The $street is dependent on the $neighborhood, that is, to see the street, you have to choose the neighborhood (dynamic).
– Nilson Lopes
I get it. It’s something more complex than I imagined, I don’t think I can help you... What I can recommend, to try to help, is that you have q detect the event of change of that element (neighborhood) and call a function that will make the request in your API, return the data in JSON, and then you make one . append() in the parent div (select) creating a new <option> element passing value and name with q Voce received from that API... I know giving you the ready code would be right, but even I don’t know how to do it, I just have an idea of what can be done. I hope I’ve helped in some way.
– Raphael Vizoni