mercredi 4 février 2015

jquery save checkbox to input type

i try to get value from multiple checkbox value. everything is fine until i try to move to next page. when i move to next page value from checkbox before was replace by new one from other page. this is my code:



<?php
if(count($data) > 0){
$no=0;
foreach($data as $r){?>
<tr valign="top">
<td><input type="checkbox" name="customer_id[]" class="chkbox" id="customer_id" value="<?php echo $r->CUSTOMER_ID;?>" style="margin:10px"/></td>
<td><?php echo ++$no;;?></td>
<td><?php echo $r->CUSTOMER_NAME;?></td>
<td><?php echo $r->ATTENTION_TO;?></td>
<td><?php echo $r->ADDRESS;?></td>
<td><?php echo $r->PHONE_NUMBER;?></td>
<td><?php echo $r->ZIP_CODE;?></td>
<td align="right">
<?php link_action($links_table_item,$r->CUSTOMER_ID);?>
</td>

</tr>
<?php }
}
?>
<form name ="sample" >
<input type="text" name="textname" id="txtValue" class="DISTRIBUTION">
</form>


this my javascript:



$(".chkbox").change(function () {
setValue();
});

function setValue() {
var items = $(".chkbox");
var result = [];
for (var i = 0; i < items.length; i++) {
var item = $(items[i]);
if (item.is(":checked")) {
result.push(item.val());
}
}
var text = result.join(",");
$(".DISTRIBUTION").val(text);
}




Aucun commentaire:

Enregistrer un commentaire