|
|
|
สอบถามเรื่องเช็คค่าว่าง radio ลองทำดูแล้ว แต่ไม่เช็คค่าให้ค่ะ |
|
|
|
|
|
|
|
สวัสดีค่ะพี่ๆทุกคน มีเรื่องจะสอบถามค่ะ
เรื่องการเช็คค่าว่าง radio ลองเขียนดูแล้ว แต่มันไม่เช็คค่าให้ค่ะ ขึ้นประโยคนี้ค่ะ Column 'sem_q1' cannot be null
ไม่รู้ว่าเขียนโค้ดผิดตรงส่วนไหน ฝากดูให้ด้วยนะคะ
Code (PHP)
<?php require_once('Connections/con_nect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO ass_seminar (sem_q1, sem_q2, sem_q3) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['sem_q1'], "int"),
GetSQLValueString($_POST['sem_q2'], "int"),
GetSQLValueString($_POST['sem_q3'], "int"));
mysql_select_db($database_con_nect, $con_nect);
$Result1 = mysql_query($insertSQL, $con_nect) or die(mysql_error());
$insertGoTo = "#";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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>แบบประเมินการนำเสนอสัมมนาหลังฝึกประสบการณ์วิชาชีพ</title>
</head>
<body>
<script language="javascript">
function fncSubmit()
{
if(document.frmMain.sem_q1.checked == false)
{
alert('Please Click Radio Option');
return false;
}
if(document.frmMain.sem_q2.checked == false)
{
alert('Please Click Radio Option');
return false;
}if(document.frmMain.sem_q3.checked == false)
{
alert('Please Click Radio Option');
return false;
}
document.frmMain.submit();
}
</script>
<form action="<?php echo $editFormAction; ?>" method="post" name="frmMain" id="frmMain" onSubmit="JavaScript:return fncSubmit();">
<center><table width="680" border="0" >
<thead>
<tr>
<td rowspan="2" align="center">รายการประเมิน</td>
<td colspan="5" align="center">ค่าคะแนน</td>
</tr>
<tr>
<td width="47" align="center">5</td>
<td width="44" align="center">4</td>
<td width="47" align="center">3</td>
<td width="41" align="center">2</td>
<td width="40" align="center">1</td>
</tr>
</thead>
<tbody>
<tr>
<td align="left" valign="baseline" nowrap="nowrap">1. การนำเสนอผลงาน</td>
<td align="center"><input type="radio" id="s1_1" name="sem_q1" value="5" /></td>
<td align="center"><input type="radio" id="s1_2" name="sem_q1" value="4" /></td>
<td align="center"><input type="radio" id="s1_3" name="sem_q1" value="3" /></td>
<td align="center"><input type="radio" id="s1_4" name="sem_q1" value="2" /></td>
<td align="center"><input type="radio" id="s1_5" name="sem_q1" value="1" /></td>
</tr>
<tr>
<td align="left" valign="baseline" nowrap="nowrap">2. การจัดการเวลา</td>
<td align="center"><input type="radio" id="s2_1" name="sem_q2" value="5" /></td>
<td align="center"><input type="radio" id="s2_2" name="sem_q2" value="4" /></td>
<td align="center"><input type="radio" id="s2_3" name="sem_q2" value="3" /></td>
<td align="center"><input type="radio" id="s2_4" name="sem_q2" value="2" /></td>
<td align="center"><input type="radio" id="s2_5" name="sem_q2" value="1" /></td>
</tr>
<tr>
<td align="left" valign="baseline" nowrap="nowrap">3. การตอบคำถาม</td>
<td align="center"><input type="radio" id="s3_1" name="sem_q3" value="5" /></td>
<td align="center"><input type="radio" id="s3_2" name="sem_q3" value="4" /></td>
<td align="center"><input type="radio" id="s3_3" name="sem_q3" value="3" /></td>
<td align="center"><input type="radio" id="s3_4" name="sem_q3" value="2" /></td>
<td align="center"><input type="radio" id="s3_5" name="sem_q3" value="1" /></td>
</tr>
<!-- <tr valign="baseline">
<td nowrap="nowrap" align="right">รวม</td>
<td><input type="text" id="sem_sum" name="sem_sum" value="" size="3"></td>
</tr> -->
</tbody>
<tr>
<tfoot>
<tr>
<td height="28" colspan="6" align="right" valign="baseline" nowrap="nowrap">
<input type="submit" value="ส่งคำตอบ" />
<td></td>
</tr>
</tfoot>
</td>
</tr>
</table>
<p> </p>
</center>
<p>
<input type="hidden" name="MM_insert" value="form2" />
</p>
</form>
<p> </p>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2013-04-27 11:32:14 |
By :
gosling |
View :
911 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก็ตามนั้นมัน มันเป็นค่า null ครับ
JavaScript HTML Check Radio Button
|
|
|
|
|
Date :
2013-04-27 15:02:44 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
if((document.frmMain.s1_1.checked == false) && (document.frmMain.s1_2.checked == false) && (document.frmMain.s1_3.checked == false) && (document.frmMain.s1_4.checked == false) && (document.frmMain.s1_5.checked == false))
{
alert('Please Click Radio Option');
return false;
}
|
|
|
|
|
Date :
2013-04-27 15:04:06 |
By :
iieszz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณพี่วินและคุณiieszz มากๆค่ะสำหรับคำแนะนำ
ทำได้แล้ว
|
|
|
|
|
Date :
2013-04-27 15:54:03 |
By :
gosling |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|