Recover data in the database by checkbox

0

Good afternoon

I'm having difficulty retrieving the data in the database via checkbox.

<div class="container">
    <div class="row">
        <form action="resultado.php" multiple method="post">
            <h3>Bairros</h3>
            <p><input type="checkbox" name="bairro[]" value="Bairro de Fátima"/>Bairro de Fátima</p>
            <p><input type="checkbox" name="bairro[]" value="Benfica"/>Benfica</p>
            <p><input type="checkbox" name="bairro[]" value="Caju"/>Caju</p>
            <p><input type="checkbox" name="bairro[]" value="Catumbi"/>Catumbi</p>
            <p><input type="checkbox" name="bairro[]" value="Centro"/>Centro</p>

            <input type="hidden" name="acao" value="Enviar"/>
            <input type="submit" value="Enviar"/>
        </form>
        <br>
    </div>
</div>  
    
asked by anonymous 09.08.2018 / 17:26

1 answer

0

$(function(){
$( "#enviar" ).click(function() {



$("input[type=checkbox][name='bairro[]']:checked").each(function(){
    alert($(this).val());
});
  
});

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="container">
<div class="row">

<h3>Bairros</h3>
<p><input type="checkbox" name="bairro[]" value="Bairro de Fátima"/>Bairro de Fátima</p>
<p><input type="checkbox" name="bairro[]" value="Benfica"/>Benfica</p>
<p><input type="checkbox" name="bairro[]" value="Caju"/>Caju</p>
<p><input type="checkbox" name="bairro[]" value="Catumbi"/>Catumbi</p>
<p><input type="checkbox" name="bairro[]" value="Centro"/>Centro</p>

<input type="hidden"  name="acao" value="Enviar"/>
<input type="submit" id="enviar" value="Enviar"/>


</div>
</div>
    
10.08.2018 / 18:54