I need to select several checkboxes that are not together and put them in a input
type text
, I achieved that by filtering "states" and selecting them I put them in input
.
But when doing another search, delete the checkbox
previously chosen.
Script to dynamically search for states
<script>
function buscar() {
var textoBusqueda = $("input#busqueda").val();
if (textoBusqueda != "") {
$.post("prueba_buscar.php", {valorBusqueda: textoBusqueda}, function(mensaje) {
$("#resultadoBusquedaEstado").html(mensaje);
});
}
else {
p= "_";
$.post("prueba_buscar.php", {valorBusqueda: p}, function(mensaje) {
$("#resultadoBusquedaEstado").html(mensaje);
});
};
};
</script>
Script to group selected checkbox
<script>
$(document).ready(function(){
$('.check').click(function() {
var ids;
ids = $('input[type=checkbox]:checked').map(function() {
return $(this).attr('id');
}).get();
$('#status1').val(ids.join(', '));
});
});
</script>