|
|
|
ขอวิธีทำ javascript check all เหมือนใน hotmail หน่อยครับ |
|
|
|
|
|
|
|
คุณได้สิธินั้นเดี๋ยวนี้ครับ (จัดไป)
Code (PHP)
<?php
include ('conf/config.php');
include('conf/opendb.php');
$sql="SELECT id, title, author, DATE_FORMAT(date, '%M %d, %Y') as sd FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table border="0" cellpadding="0" cellspacing="0" class="adminlist">
<tr id="top">
<th width="5" align="center">Id</th>
<th width="5" align="center">#</th>
<th>Title</th>
<th width="200" align="center">Author</th>
<th width="100" align="center">Date</th>
<th width="80" align="center">Delete</th>
<th width="20" align="center">Edit</th>
</tr>
<?php
while($rows = mysql_fetch_array($result)){
?>
<tr>
<td width="5" align="center"><? echo $rows['id']; ?></td>
<td width="5" align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<td><? echo $rows['title']; ?></td>
<td width="200" align="center"><? echo $rows['author']; ?></td>
<td width="100" align="center"><? echo $rows['sd']; ?></td>
<td width="80" align="center" id="trash"><a href="delete_news.php?id=<? echo $rows['id']; ?>">Delete</a></td>
<td width="20" align="center" id="edit"><a href="edit_news.php?id=<? echo $rows['id']; ?>">Edit</a></td>
<?php
}
?>
<tr>
<td colspan="7" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td>
</tr>
<?
// Check if delete button active, start this
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
$result = mysql_query($sql);
}
// if successful redirect to delete_multiple.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=post_manage.php\">";
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
|
|
|
|
|
Date :
2009-09-15 09:43:49 |
By :
NanoTHoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PageMultiCheckbox1.html)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form action="PageMultiCheckbox2.php" method="post" name="form1">
Please select color.<br>
<input type="checkbox" name="chkColor[]" value="Red">Red<br>
<input type="checkbox" name="chkColor[]" value="Blue">Blue<br>
<input type="checkbox" name="chkColor[]" value="Green">Green<br>
<input type="checkbox" name="chkColor[]" value="Orange">Orange<br>
<input type="checkbox" name="chkColor[]" value="Black">Black<br>
<input name="btnSubmit" type="submit" value="Submit">
</form>
</body>
</html>
Code (PageMultiCheckbox2.php)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?
for($i=0;$i<count($_POST["chkColor"]);$i++)
{
if(trim($_POST["chkColor"][$i]) != "")
{
echo "chkColor $i = ".$_POST["chkColor"][$i]."<br>";
}
}
?>
</body>
</html>
|
|
|
|
|
Date :
2009-09-15 09:51:30 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
<html>
<head>
<script type="text/javascript">
function check()
{
document.getElementById("myCheck").checked=true;
document.getElementById("myCheck2").checked=true;
document.getElementById("myCheck3").checked=true;
}
function uncheck()
{
document.getElementById("myCheck").checked=false;
document.getElementById("myCheck2").checked=false;
document.getElementById("myCheck3").checked=false;
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="myCheck" />
<input type="checkbox" id="myCheck2" />
<input type="checkbox" id="myCheck3" />
<input type="button" onclick="check()" value="Check Checkbox" />
<input type="button" onclick="uncheck()" value="Uncheck Checkbox" />
</form>
</body>
</html>
?>
|
|
|
|
|
Date :
2009-09-15 09:55:24 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
if (!empty($_POST['c'])){
$ids_string = "'".implode("','",$_POST['c'])."'";
$sql = "DELETE FROM tb WHERE id IN({$ids_string})";
echo $sql;
//mysql_query($sql);
}
?>
<script type="text/javascript">
function cSet(clist,n){
for(var i=0;i<clist.length;i++){
clist[i].checked = n;
}
}
</script>
<form name="form1" method="post">
<input type="button" onclick="cSet(this.form['c[]'],1);" value="check all" />
<input type="button" onclick="cSet(this.form['c[]'],0);" value="clear all" />
<!-- value หมายถึง id ของ record -->
<input type="checkbox" name="c[]" value="1" />
<input type="checkbox" name="c[]" value="2" />
<input type="checkbox" name="c[]" value="3" />
<input type="submit" value="enter" />
</form>
ref: http://cakephp.jitwitya.com/post/check-all-checkbox-button
|
|
|
|
|
Date :
2009-09-15 10:03:32 |
By :
num |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มาหลายแนวเลย เข้ามาเก็บเอาไปใช้คับ
|
|
|
|
|
Date :
2009-09-15 11:38:38 |
By :
chaiwit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นายแน่มาก
|
|
|
|
|
Date :
2009-09-15 12:36:16 |
By :
nilas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วคุณลาชินิลาสไม่แน่เหรอ ฮาๆๆๆๆ แน่จริงเจอกับพี่เสกได้เลย ได้ข่าวว่าจะเลี้ยงน้ำดอกอัญชัญ อิอิอิ
|
|
|
|
|
Date :
2009-09-15 13:18:42 |
By :
NanoTHoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอ่อ เปลี่ยนเป็นน้ำยาเร่งรากแล้วครับ
|
|
|
|
|
Date :
2009-09-15 13:22:26 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ระวังรากมากๆ จะถอนไม่ขึ้นนะครับ
อิอิอิ
|
|
|
|
|
Date :
2009-09-15 15:00:28 |
By :
NanoTHoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มะค่อยนะ คนที่นี้เก่งๆ กันทั้งนั้น
|
|
|
|
|
Date :
2009-09-15 15:17:14 |
By :
nilas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ง่ายๆ ผมก็พอให้ แต่ ยากๆ นี้ ให้ ท่านอื่น อย่างคุณ เล็กๆ(nano) อิอิ
|
|
|
|
|
Date :
2009-09-15 15:21:04 |
By :
nilas |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณลาชินิลาส เจ้าฟังก์ชั่นเล็กๆ นี่ไว้ทำอะไรหรือครับ ถ้าไว้ทำให้เล็กลง เล็กลงนี่ อย่าเอามา " เล็กๆ(nano)" นะครับ เพราะผมกลัว เล็กๆ อิอิอิอิ (หมายถึงเข็มนะ อย่าคิดลึก) ฮาาาา
|
|
|
|
|
Date :
2009-09-15 17:57:02 |
By :
NanoTHoro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>
Ref : PHP MySQL Multiple Checkbox Delete Record
|
|
|
|
|
Date :
2009-10-17 09:08:13 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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:56:49 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|