javascript - How to make an relative search ( informed by user ) -
i have lot of checkboxs :
the user check 1 param of each checkbox make search.
how can relative search informed user ? isn't obligatted select 1 of each checkbox.
my js:
var checkeds = new array(); $("input[name='marcar[]']:checked").each(function (){ checkeds.push( $(this).val()); }); var obj = $("#paramspesquisa"); if($(obj).find("input[id='cd_seq_pedido']:checked").length > 0){ var cd_seq_pedido = $(obj).find("input[id='cd_seq_pedido']:checked").val(); }else{ var cd_seq_pedido = ""; }
my ajax:
$.ajax({ type: "post", url: "/pedidoonline/index.php/pedidos/checkbox_marcados", data: { 'marcar':checkeds, 'cd_seq_pedido': cd_seq_pedido, 'cd_pedido': cd_pedido }, success: function(data){ console.log(data); } });
on controller, how can make query ?
$pesquisa = $this->pesquisapedonline->find('all', array( 'fields' => array('cd_seq_pedido', 'cd_pedido', 'ds_cpl_tamanho_interno'), 'conditions' => array(?????) ));
if need more information, i'll put, sorry if couldn't explain clearly.
when build conditions array in cake need specify field each of checkbox values corresponds with. example:
$conditions = array( 'modelname.fieldname1' => 'value1', // single checkbox value 'modelname.fieldname2' => 'value2, value3, value4', // multiple checkbox values // etc... );
to able construct $conditions
array need pass more information controller in ajax call. suggest constructing json object can build {'fieldname1':'value1, value2'}
.
also may want consider how remove items user unchecks.
Comments
Post a Comment