I'm sending neighborhoods through $ _GET through a form and would like to dynamically mark them in the screen update thus making a system persistence of the results sought.
<fieldset class="normal">
<input type="checkbox" name="bairros[]" value="BELEM NOVO" id="BELEM NOVO">
<label for="BELEM NOVO">Belém Novo</label>
<input type="checkbox" name="bairros[]" value="BOM FIM" id="BOM FIM">
<label for="BOM FIM">Bom Fim</label>
<input type="checkbox" name="bairros[]" value="SANTA CLARA" id="SANTA CLARA">
<label for="SANTA CLARA">Santa Clara</label>
</fieldset>
I include the file bairros.php
shortly after body with require and capture all neighborhoods that were marked on the form with $ _GET on page return.
# Persistencia dos bairros
$inbairros = $_GET["bairros"];
if(array_key_exists("bairros", $_GET)){
foreach($inbairros as $baitem => $bavalue) {
// select bairros
}
}
If I do echo $bavalue
within foreach
, logically it returns me all neighborhoods that were selected on the form. The value
of the input contains the same content.