checkbox update the record using jquery?
Posted
by python
on Stack Overflow
See other posts from Stack Overflow
or by python
Published on 2010-03-24T02:53:22Z
Indexed on
2010/03/24
3:13 UTC
Read the original article
Hit count: 278
jQuery
<?
include("connect.php");
$sql="select * from sampledb";
$res=mysql_query($sql) or die("query failed");
?>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript">
function updateCheckVal() {
var valcheck = [];
$('#checkbox :checked').each(function() {
valcheck.push($(this).val());
});
$('#store_checkbox').val(valcheck)
}
$(function() {
$('#checkbox input').click(updateCheckVal);
updateCheckVal();
});
$(function(){
$("a.modify").click(function(){
var val = [];
$(':checkbox:checked').each(function(i){
val[i] = $(this).val();
});
$("#deleted_id").val(val);
page=$(this).attr("href");
$("#Formcontent").html("loading...").load(page);
return false;
});
});
</script
<form name="">
<table width="100%" border="1" cellpadding="1" cellspacing="1">
<thead>
<tr bgcolor="#CCCCCC">
<th></th>
<th>ID</th>
<th>Fullname</th>
</tr>
</thead>
<tbody>
<? while($row=mysql_fetch_assoc($res)){?>
<tr>
<td id="checkbox"><input type="checkbox" name="chk[]" class="chk" value=<?php echo $row["student_id"];?> ></td>
<td><?php echo $row["id"];?></td>
<td><?php echo $row["fullname"];?></td>
</tr>
<? }?>
</tbody>
</table>
<input type="hidden" name="store_checkbox" id="store_checkbox" value="">
<a href="formstudent.php?action=update&id=<?php echo $_POST["store_checkbox"]; ?>" class="modify">modify</a>
I want to pass the checkbox value that is checked in something like this:
example :formstudent.php?action=update&id=1,
I am doing here is pass like this but does not work.
<a href="formstudent.php?action=update&id=<?php echo $_POST["store_checkbox"]; ?>"
Anybody know how to do this?
© Stack Overflow or respective owner