สอบถามเรื่องการ Checkbox ตรวจสอบค่าที่ส่งไปแต่ละหน้าครับ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา สอบถามเรื่องการ Checkbox ตรวจสอบค่าที่ส่งไปแต่ละหน้าครับ
สอบถามเรื่องการ Checkbox ตรวจสอบค่าที่ส่งไปแต่ละหน้าครับ
Copy
Code หน้าแรกนะครับ
เป็นหน้า home หน้านี้ลงฐานข้อมูลด้วยครับ
หน้านี้มี Function ของ Jquery ด้วยครับ โดยการ ติ๊กที่ checkbox แล้วไห้ radio disbled
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="email1.php">
<table width="876" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="30" colspan="2" valign="top">4.1 Email 1</td>
<td width="30" valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second');" id="checkbox1"></td>
<td width="262" valign="center"><input type="radio" name="radio" class="second" id="radio" value="radio" />
<input type="radio" name="radio" class="second" id="radio2" value="radio" />
<input type="radio" name="radio" class="second" id="radio3" value="radio" />
<input type="radio" name="radio" class="second" id="radio4" value="radio" />
<input type="radio" name="radio" class="second" id="radio5" value="radio" />
<input type="radio" name="radio" class="second" id="radio6" value="radio" />
<input type="radio" name="radio" class="second" id="radio7" value="radio" />
<input type="radio" name="radio" class="second" id="radio8" value="radio" />
<input type="radio" name="radio" class="second" id="radio9" value="radio" />
<input type="radio" name="radio" class="second" id="radio10" value="radio" /></td>
<td width="115"> </td>
<td width="339"> </td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.2 Email 2</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second2');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second2" id="radio" value="radio" />
<input type="radio" name="radio" class="second2" id="radio2" value="radio" />
<input type="radio" name="radio" class="second2" id="radio3" value="radio" />
<input type="radio" name="radio" class="second2" id="radio4" value="radio" />
<input type="radio" name="radio" class="second2" id="radio5" value="radio" />
<input type="radio" name="radio" class="second2" id="radio6" value="radio" />
<input type="radio" name="radio" class="second2" id="radio7" value="radio" />
<input type="radio" name="radio" class="second2" id="radio8" value="radio" />
<input type="radio" name="radio" class="second2" id="radio9" value="radio" />
<input type="radio" name="radio" class="second2" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.3 Email 3</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second3');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second3" id="radio" value="radio" />
<input type="radio" name="radio" class="second3" id="radio2" value="radio" />
<input type="radio" name="radio" class="second3" id="radio3" value="radio" />
<input type="radio" name="radio" class="second3" id="radio4" value="radio" />
<input type="radio" name="radio" class="second3" id="radio5" value="radio" />
<input type="radio" name="radio" class="second3" id="radio6" value="radio" />
<input type="radio" name="radio" class="second3" id="radio7" value="radio" />
<input type="radio" name="radio" class="second3" id="radio8" value="radio" />
<input type="radio" name="radio" class="second3" id="radio9" value="radio" />
<input type="radio" name="radio" class="second3" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.4 Email 4</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second4');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second4" id="radio" value="radio" />
<input type="radio" name="radio" class="second4" id="radio2" value="radio" />
<input type="radio" name="radio" class="second4" id="radio3" value="radio" />
<input type="radio" name="radio" class="second4" id="radio4" value="radio" />
<input type="radio" name="radio" class="second4" id="radio5" value="radio" />
<input type="radio" name="radio" class="second4" id="radio6" value="radio" />
<input type="radio" name="radio" class="second4" id="radio7" value="radio" />
<input type="radio" name="radio" class="second4" id="radio8" value="radio" />
<input type="radio" name="radio" class="second4" id="radio9" value="radio" />
<input type="radio" name="radio" class="second4" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.5 Email 5</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second5');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second5" id="radio" value="radio" />
<input type="radio" name="radio" class="second5" id="radio2" value="radio" />
<input type="radio" name="radio" class="second5" id="radio3" value="radio" />
<input type="radio" name="radio" class="second5" id="radio4" value="radio" />
<input type="radio" name="radio" class="second5" id="radio5" value="radio" />
<input type="radio" name="radio" class="second5" id="radio6" value="radio" />
<input type="radio" name="radio" class="second5" id="radio7" value="radio" />
<input type="radio" name="radio" class="second5" id="radio8" value="radio" />
<input type="radio" name="radio" class="second5" id="radio9" value="radio" />
<input type="radio" name="radio" class="second5" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.6 Email 6</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second6');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second6" id="radio" value="radio" />
<input type="radio" name="radio" class="second6" id="radio2" value="radio" />
<input type="radio" name="radio" class="second6" id="radio3" value="radio" />
<input type="radio" name="radio" class="second6" id="radio4" value="radio" />
<input type="radio" name="radio" class="second6" id="radio5" value="radio" />
<input type="radio" name="radio" class="second6" id="radio6" value="radio" />
<input type="radio" name="radio" class="second6" id="radio7" value="radio" />
<input type="radio" name="radio" class="second6" id="radio8" value="radio" />
<input type="radio" name="radio" class="second6" id="radio9" value="radio" />
<input type="radio" name="radio" class="second6" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="30" colspan="2" valign="top">4.7 Email 7</td>
<td valign="center"><input type="checkbox" name="first" value="Disable" onClick="setCheck(this,'second7');" id="checkbox1"></td>
<td valign="center"> <input type="radio" name="radio" class="second7" id="radio" value="radio" />
<input type="radio" name="radio" class="second7" id="radio2" value="radio" />
<input type="radio" name="radio" class="second7" id="radio3" value="radio" />
<input type="radio" name="radio" class="second7" id="radio4" value="radio" />
<input type="radio" name="radio" class="second7" id="radio5" value="radio" />
<input type="radio" name="radio" class="second7" id="radio6" value="radio" />
<input type="radio" name="radio" class="second7" id="radio7" value="radio" />
<input type="radio" name="radio" class="second7" id="radio8" value="radio" />
<input type="radio" name="radio" class="second7" id="radio9" value="radio" />
<input type="radio" name="radio" class="second7" id="radio10" value="radio" /></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="47" colspan="5" valign="top"><p>เมื่อ Click ที่ Email นั้นๆ จะไม่สามารถทำหน้านั้นได้แต่หน้าอื่นสามารถทำได้ </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td width="113" height="38" valign="top"><input type="submit" name="button" id="button" value="Submit" />
<label></label></td>
<td width="17"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="210"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
});
var setCheck = function(chkObj,cssObj){
var i_check=$(chkObj).prop("checked");
if(i_check==true){
$("."+cssObj).prop("checked",false).attr('disabled', true);
}else{
$("."+cssObj).attr('disabled', false);
}
};
</script>
</body>
</html>
หน้าที่ 1 คือ email 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail1.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 1 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Save ที่หน้า 1
Save ที่หน้า 1
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email2.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E1)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 2 คือ email 2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail2.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 2 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email3.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E2)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 3 คือ email 3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail3.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 3 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email4.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E3)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 4 คือ email 4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail4.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 4 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Save ที่หน้า 4
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email5.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E4)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 5 คือ email 5
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail5.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 5 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Save ที่หน้า 5
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email6.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E5)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 6 คือ email 6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail6.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 6 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Save ที่หน้า 6
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=email7.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E6)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
หน้าที่ 7 คือ email 7
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="saveemail7.php">
<table width="404" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="133" height="28" valign="top">Email 7 ดีเท่าไหร่</td>
<td width="271" valign="top"><input type="radio" name="radio" id="radio" value="1" />
<input type="radio" name="radio" id="radio" value="2" />
<input type="radio" name="radio" id="radio" value="3" />
<input type="radio" name="radio" id="radio" value="4" />
<input type="radio" name="radio" id="radio" value="5" />
<input type="radio" name="radio" id="radio" value="6" />
<input type="radio" name="radio" id="radio" value="7" />
<input type="radio" name="radio" id="radio" value="8" />
<input type="radio" name="radio" id="radio" value="9" />
<input type="radio" name="radio" id="radio" value="10" /></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
<tr>
<td height="65"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
Save ที่หน้า 7
<META HTTP-EQUIV='Refresh' CONTENT = '0;URL=home.php'>
<?
include ('connect.php');
$sql = "insert into email1 (E7)
VALUES ('$_POST[radio]')";
$result = mysql_query($sql);
if($result)
{
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: No Complete [".$result."]');";
echo"</script>";
}
mysql_close();
?>
ผมอยากจะถามว่า ถ้าผมคลิ๊กที่ Email 1 ในหน้า home พอผมบันทึกลงฐานข้อมูลเสร็จผมจะไม่สามารถทำหน้า Email1 ได้เลยครับ แต่สามารถทำ Email 2-7 ได้ เพราะผมไม่ได้ ติ๊ก
และถ้าผม ติ๊ก Email2 กับ Email7 ผมก้อสามารถทำหน้า Email1 Email3 และ Email4 Email5 Email6 ได้ครับ แนวนี้
ผมตันอยู่หลายวันเลยครับ ไม่รุ้จะไช้วิธีไหน มือใหม่นะครับ รบบกวนด้วยครับผม

คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ