1
How do I take all checkbox values that are checked and move to GET.
$("#subcategoria").click(function(){
var checados = [];
$.each($("input[name='subcategoria[]']:checked"), function(){
$.get("inc_habilidades.php",
{id:checados.push($(this).val()), opcao:'2'},
function(valor2){
$("#habilidades").html(valor2).chosen("destroy");
}
)
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="">
<input class="subcategoria" type="checkbox" name="subcategoria[]" value="1" />teste1<br>
<input class="subcategoria" type="checkbox" name="subcategoria[]" value="2" />teste2<br>
<input class="subcategoria" type="checkbox" name="subcategoria[]" value="3" />teste3<br>
<input class="subcategoria" type="checkbox" name="subcategoria[]" value="4" />teste4
</form>
I added a new script to my answer downstairs. I did a treatment where the array
checados
will only have the values of the boxes checked.– Sam
in php $id = implode( ",", $_GET['subcategory'] );
– user60252