|
|
|
รบกวนช่วยดูให้ที่ครับ พอดีเช็คค่าว่างใน radio ได้แล้ว แต่แค่ติ้กสักอันเดียวมันกับเป็นเซพให้ |
|
|
|
|
|
|
|
รบกวนช่วยดูให้ที่ครับ พอดีเช็คค่าว่างใน radio ได้แล้ว แต่แค่ติ้กสักอันเดียวมันกับเป็นเซพให้
*****อยากให้ติ้กให้ครบก่อนแล้วถึงจะทำการเซพอ่าครับ*****
Code (PHP)
<?php
$form_id = $_GET["select"];
include "connectdatabase.php";
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($qry)){
$id = $row['qtn_id'];
echo '<script type="text/javascript">';
echo "var id = '$id';";
echo '</script>';
?>
<script type="text/javascript">
function fncSubmit()
{
if(document.getElementById('c_id1'+id+'').checked == false && document.getElementById('c_id2'+id+'').checked == false )
{
alert('Please Check All Before Save');
return false;
}
}
</script>
<?
}
?>
<form name="frmMain" method="POST" action="<?=$_SERVER["PHP_SELF"];?>?Page=<?=$Page;?>&select=<?=$_GET["select"];?>" onSubmit="JavaScript:return fncSubmit();"><p>
<input type="hidden" name="hdnCmd" value="">
<?php
$form_id = $_GET["select"];
include "connectdatabase.php";
$sql = "SELECT * FROM question_form WHERE qfrm_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error($sql));
$row = mysql_fetch_array($qry);
echo '<center>','<h3>',$row['qfrm_title'],'</h3>','</center>';
?>
<table width="1000" border="1" align="center">
<tr>
<th width="1015" scope="col" bgcolor="#2f4f4f">หัวข้อการตรวจสอบ</th>
<th width="85" scope="col" bgcolor="#2f4f4f">สอดคล้อง</th>
<th width="85" scope="col" bgcolor="#2f4f4f">บกพร่อง</th>
</tr>
<?php
include "connectdatabase.php";
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
?>
<? while($row = mysql_fetch_array($qry)){
$titleid = $row['qtn_title_id'];
$title = $row['qtn_title'];
$id = $row['qtn_id'];
?>
<tr bgcolor="#CCCCCC">
<td><h4><?=$row['qtn_title_id']?></h4><p>
<?=$row['qtn_title']?></td>
<td><center><input type="radio" name="choose<?=$row['qtn_id']?>" id="c_id1<?=$id?>" value="1"/></center></td>
<td><center><input type="radio" name="choose<?=$row['qtn_id']?>" id="c_id2<?=$id?>" value="0"/></center></td>
</tr>
<?
}
?>
</table>
<p>
<center>
<input name="btnUpdate" type="submit" id="btnUpdate" value="Save" onClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input type="reset" name="Reset" value="Cancle">
</center>
</form>
<?
}
?>
<? include "connectdatabase.php";
if($_POST["hdnCmd"]=="Update")
{
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($qry)){
$id = $row['qtn_id'];
$strSQL1 = ("INSERT INTO question_answer (ans_qtn_ref,ans_qtn_value,user_id)
values ($id,".$_POST["choose$id"].",".$_SESSION["UserID"].")");
$objQuery = mysql_query($strSQL1);
}
?>
<?
}
?>
<p align="center"><img src="img/f-g4s.png" width="1007" height="30"></p>
Tag : PHP, MySQL, JavaScript, Ajax, jQuery
|
|
|
|
|
|
Date :
2014-11-05 15:43:08 |
By :
5170 |
View :
791 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาโค๊ดเต็มๆ มาดูครับ คล้ายๆ มันยังไม่ครบน่ะครับ เอาไปวางใน DW มันมีเออเร่อร์ เยอะครับ
|
|
|
|
|
Date :
2014-11-05 17:42:32 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ได้แล้วครับ แต่เหลือคือ
****เมื่อเราติ้กไม่ครบมันต้องแจ้งเตือนใช่ปะครับ แต่ของผมมันคือ ไม่ต้องติ้กอันไหนเลย แค่ติ้ก radio ล่างสุด มันกลับทำการเซพ****
ทั้งที่จิงๆแล้วไม่ควรที่จะเซพ ถ้ายังไม่ติ้กทั้งหมด แต่นี้แค่ติ้กอัน ล่างสุด มันกับเซพให้ รบกวนดูให้อีกที่ครับ
<?
session_start();
if ($_SESSION["UserID"]=='')
{
echo "<meta http-equiv='refresh' content='0;URL=index.php'>";
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style17 {font-family: Tahoma, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style18 {font-size: 14px;
font-weight: bold;
}
.style19 {
font-size: 36px;
color: #2f4f4f;
}
.style20 { font-size: 24px;
font-weight: bold;
}
.style23 {font-size: 16px}
-->
</style>
<h1 align="center"><img src="img/h-g4s.png" width="1024" height="125" align="top"></h1>
<p align="center" class="style24 style1 style19"><strong>Check List</strong></p>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="993" border="0" align="center" bgcolor="#2f4f4f">
<tr>
<th width="950"><span class="style17"><span class="style18">select Department :</span>
<select name="select" id="select">
<option selected="selected">Choose Department</option>
<option value="1">MSS</option>
<option value="2">FSS</option>
</select>
</span>
<input type="submit" value="OK."></th>
</tr>
</table>
</form>
<form name="form4" method="post" action="auditor_page.php">
<div align="center"><br>
<input name="imageField" type="image" src="img/back-to-menu.png" width="120" height="30" border="0">
</div>
</form>
<?
if($_GET["select"] != "")
{
include "connectdatabase.php";
$strSQL = "SELECT * FROM question_form WHERE (".$_GET["select"].")";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
mysql_query('SET NAME UTF8');
mysql_query('SET character_set_results=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_connection=utf8');
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 20; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
//$strSQL .=" order by No ASC LIMIT $Page_Start , $Per_Page";
//$objQuery = mysql_query($strSQL);
?>
<?php
$form_id = $_GET["select"];
include "connectdatabase.php";
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($qry)){
$id = $row['qtn_id'];
echo '<script type="text/javascript">';
echo "var id = '$id';";
echo '</script>';
?>
<script type="text/javascript">
function fncSubmit()
{
if(document.getElementById('c_id1'+id+'').checked == false && document.getElementById('c_id2'+id+'').checked == false )
{
alert('Please Check All Before Save \n(กรุณาตรวจสอบให้ครบทั้งหมดก่อนการบันทึก)');
return false;
}
}
</script>
<?
}
?>
<form name="frmMain" method="POST" action="<?=$_SERVER["PHP_SELF"];?>?Page=<?=$Page;?>&select=<?=$_GET["select"];?>" onSubmit="JavaScript:return fncSubmit();"><p>
<input type="hidden" name="hdnCmd" value="">
<?php
$form_id = $_GET["select"];
include "connectdatabase.php";
$sql = "SELECT * FROM question_form WHERE qfrm_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error($sql));
$row = mysql_fetch_array($qry);
echo '<center>','<h3>',$row['qfrm_title'],'</h3>','</center>';
?>
<table width="1000" border="1" align="center">
<tr>
<!--<th width="85" scope="col" bgcolor="#2f4f4f">ลำดับ</th>-->
<th width="1015" scope="col" bgcolor="#2f4f4f">หัวข้อการตรวจสอบ</th>
<th width="85" scope="col" bgcolor="#2f4f4f">สอดคล้อง</th>
<th width="85" scope="col" bgcolor="#2f4f4f">บกพร่อง</th>
</tr>
<?php
include "connectdatabase.php";
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
?>
<? while($row = mysql_fetch_array($qry)){
$titleid = $row['qtn_title_id'];
$title = $row['qtn_title'];
$id = $row['qtn_id'];
?>
<tr bgcolor="#CCCCCC">
<!--<td><center><?=$row['qtn_id']?></center></td>-->
<td><h4><?=$titleid?></h4><p>
<?=$title?></td>
<td><center><input type="radio" name="choose<?=$id?>" id="c_id1<?=$id?>" value="1"/></center></td>
<td><center><input type="radio" name="choose<?=$id?>" id="c_id2<?=$id?>" value="0"/></center></td>
</tr>
<?
}
?>
</table>
<p>
<center>
<input type="submit" name="submit" value="Save" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input type="reset" name="Reset" value="Cancle">
</center>
</form>
<?
}
?>
<? include "connectdatabase.php";
if($_POST["hdnCmd"]=="Update")
{
if(isset($_POST['submit']))
{
echo "<script>alert('Save Check List Completed');</script>";
$sql = "SELECT * FROM question_list
WHERE qtn_form_id = $form_id";
$qry = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($qry)){
$id = $row['qtn_id'];
$strSQL1 = ("INSERT INTO question_answer (ans_qtn_ref,ans_qtn_value,user_id)
values ($id,".$_POST["choose$id"].",".$_SESSION["UserID"].")");
$objQuery = mysql_query($strSQL1);
}
}
?>
<?
}
?>
<p align="center"><img src="img/f-g4s.png" width="1007" height="30"></p>
|
|
|
|
|
Date :
2014-11-06 13:24:13 |
By :
5170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|