|
|
|
check all ช่วยหน่อยนะคับ ผมทำ checkall ได้แล้ว แต่ว่าไม่สามารถส่งค่า checkbox ไปอีกเพจนึงได้อ่ะคับ |
|
|
|
|
|
|
|
<th scope="col"><input name="Checkbox[]" type="checkbox" value="<?=$row["id_stu"]?>" onclick = "check(this);"></th>
|
|
|
|
|
Date :
4 ธ.ค. 2550 15:52:58 |
By :
lozomac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าใส่array ตรง checkbox แล้วมันไม่ยอม checkall ให้อ่ะคับ ทำยังไงดี
|
|
|
|
|
Date :
4 ธ.ค. 2550 16:48:22 |
By :
o |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script language="JavaScript">
function checkall()
{
box = eval("document.checkForm.Checkbox[]");
box.checked = !box.checked;
}
|
|
|
|
|
Date :
4 ธ.ค. 2550 18:06:58 |
By :
lozomac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันยังไม่ check all ให้เรยอ่ะ ช่วยหน่อยนะคับ
|
|
|
|
|
Date :
4 ธ.ค. 2550 19:23:32 |
By :
o |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phpMySQLDeleteMultiRecordList.php
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<script language="JavaScript">
function onDelete()
{
if(confirm('Do you want to delete ?')==true)
{
return true;
}
else
{
return false;
}
}
</script>
<form name="frmMain" action="phpMySQLDeleteMultiRecord.php" method="post" OnSubmit="return onDelete();">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
<th width="30"> <div align="center">Delete </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><input type="checkbox" name="chkDel[]" value="<?=$objResult["CustomerID"];?>"></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnDelete" value="Delete">
</form>
</body>
</html>
Screenshot
phpMySQLDeleteMultiRecord.php
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
for($i=0;$i<count($_POST["chkDel"]);$i++)
{
if($_POST["chkDel"][$i] != "")
{
$strSQL = "DELETE FROM customer ";
$strSQL .="WHERE CustomerID = '".$_POST["chkDel"][$i]."' ";
$objQuery = mysql_query($strSQL);
}
}
echo "Record Deleted.";
mysql_close($objConnect);
?>
</body>
</html>
เพิ่มเติมสำหรับการทำปุ่ม Check All
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<script language="JavaScript">
function ClickCheckAll(vol)
{
var i=1;
for(i=1;i<=document.frmMain.hdnCount.value;i++)
{
if(vol.checked == true)
{
eval("document.frmMain.chkDel"+i+".checked=true");
}
else
{
eval("document.frmMain.chkDel"+i+".checked=false");
}
}
}
function onDelete()
{
if(confirm('Do you want to delete ?')==true)
{
return true;
}
else
{
return false;
}
}
</script>
<form name="frmMain" action="phpMySQLDeleteMultiRecord.php" method="post" OnSubmit="return onDelete();">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
<th width="30"> <div align="center">
<input name="CheckAll" type="checkbox" id="CheckAll" value="Y" onClick="ClickCheckAll(this);">
</div></th>
</tr>
<?
$i = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
<td align="center"><input type="checkbox" name="chkDel[]" id="chkDel<?=$i;?>" value="<?=$objResult["CustomerID"];?>"></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
<input type="submit" name="btnDelete" value="Delete">
<input type="hidden" name="hdnCount" value="<?=$i;?>">
</form>
</body>
</html>
Screenshot
|
|
|
|
|
Date :
2009-10-18 07:57:57 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|