|
|
|
รบกวนช่วยดูการส่งค่าจาก Form ไปอีกหน้าหน่อยครับ ทำไมส่งไปแล้ว ไม่มีข้อมูล |
|
|
|
|
|
|
|
รบกวนช่วยดูการส่งค่าจาก Form ไปอีกหน้าหน่อยครับ ทำไมส่งไปแล้ว ไม่มีข้อมูล ลองรับแค่ค่าเดียวไปหน้า req.php ก็ไม่มีข้อมูล
หน้า form
Code (PHP)
<?
session_start();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Asset Management</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="select/docsupport/prism.css">
<link rel="stylesheet" href="select/chosen.css">
<style type="text/css" media="all">
/* fix rtl for demo */
.chosen-rtl .chosen-drop { left: 100px; }
</style>
<script language="javascript">
function fncSubmit()
{
if(document.form1.AssetCode.value == "0")
{
alert('กรุณาเลือกประเภทของอุปกรณ์ด้วยครับ');
document.form1.AssetCode.focus();
return false;
}
if(document.form1.detail.value == "")
{
alert('กรุณากรอกรายละเอียดของงานที่แจ้งด้วยครับ');
document.form1.detail.focus();
return false;
}
/*if(document.form1.itemcode.value == "0")
{
alert('กรุณาเลือกรหัสอุปกรณ์ IT ด้วยครับ');
document.form1.itemcode.focus();
return false;
} */
document.form1.submit();
}
</script>
<script language="JavaScript">
function resutName(Asset)
{
switch(Asset)
{
<?php
mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL2 = "SELECT * FROM asset";
$objQuery2 = mysql_query($strSQL2);
while($objResult2 = mysql_fetch_array($objQuery2))
{
$AssetName = trim($objResult2["AssetName"]);
?>
case "<?php echo trim($objResult2["Asset"]);?>":
form1.txtName1.value = "<?php echo str_replace('"','',$AssetName);?>";
form1.txtBrance.value = "<?php echo trim($objResult2["Location"]);?>";
form1.txtFloor.value = "<?php echo trim($objResult2["Area"]);?>";
break;
<?php
}
?>
default:
form1.txtName1.value = "";
form1.txtBrance.value = "";
form1.txtFloor.value = "";
}
}
</script>
<script language="JavaScript">
function resutNameID(user_code)
{
switch(user_code)
{
<?php
mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_select_db("dbhelpcrm");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQLID1 = "select * from user inner join dep on ref_dep_id = dep_id";
$objQueryID1 = mysql_query($strSQLID1);
while($objResultID1 = mysql_fetch_array($objQueryID1))
{
$dep = trim($objResultID1["dep_name"]);
?>
case "<?php echo ($objResultID1["user_code"]);?>":
form1.fname1.value = "<?php echo trim($objResultID1["user_name"]);?>";
form1.lname1.value = "<?php echo trim($objResultID1["user_lname"]);?>";
form1.email1.value = "<?php echo trim($objResultID1["user_email"]);?>";
form1.dep1.value = "<?php echo $dep ?>";
form1.tel1.value = "<?php echo trim($objResultID1["user_tel"]);?>";
break;
<?php
}
?>
default:
form1.fname1.value = "";
form1.lname1.value = "";
form1.email1.value = "";
form1.dep1.value = "";
form1.tel1.value = "";
}
}
</script>
</head>
<body>
<!-- start header -->
<div id="header"><br>
<?
$user_id = $_SESSION[id];
mysql_connect("localhost","root","1234");
mysql_select_db("dbhelpcrm");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("$dbname");
$strSQL="select * from user inner join dep on ref_dep_id = dep_id where user_id = '$user_id'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$rs=mysql_fetch_array($objQuery);
$user_code = $rs[user_code];
$user_name = $rs[user_name];
$user_lname = $rs[user_lname];
$user_email = $rs[user_email];
$dep_name = $rs[dep_name];
$user_tel = $rs[user_tel];
?>
<br />
</div>
<form name="form1" method="post" action="req.php" onSubmit="JavaScript:return fncSubmit();">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="7">
<tr bgcolor="#999999">
<td colspan="4"><div align="center">ผู้แจ้งงาน</div></td>
</tr>
<tr>
<td>วันที่</td>
<td colspan="3"><input name="req_curdate" id="req_curdate" type="text" disabled="disabled" value="<?=date('Y-m-d H:i:s')?>" size="25"/></td>
</tr>
<tr>
<td width="15%">ชื่อ - สกุล</td>
<td colspan="3"><input name="req_id" id="req_id" type="text" disabled="disabled" value="<?=$user_code ?>" size="10"/>
<input name="req_fname" id="req_fname" type="text" disabled="disabled" value="<?=$user_name ?>" size="20"/>
<input name="req_lname" id="req_lname" type="text" disabled="disabled" value="<?=$user_lname?>" size="20"/></td>
</tr>
<tr>
<td>อีเมล์</td>
<td colspan="3"><input name="req_email" id="req_email" type="text" disabled="disabled" value="<?=$user_email?>" size="25"/></td>
<td></td>
</tr>
<tr>
<td>แผนก</td>
<td colspan="3"><input name="req_dep_name" id="req_dep_name" type="text" disabled="disabled" value="<?=$dep_name?>" size="50"/></td>
<td width="1%"></td>
</tr>
<tr>
<td align="left">เบอร์โทร</td>
<td colspan="3"><input type="text" name="req_tel" id="req_tel" disabled="disabled" value="<?=$user_tel?>"/>
</tr>
<tr>
<td>รหัสทรัพย์สิน</td>
<td width="28%"><select name="Asset" id="Asset" class="chosen-select" style="width:150px;" tabindex="2" OnChange="resutName(this.value);">
<option value="">== รหัสทรัพย์สิน ==</option>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL ="select * from asset ORDER BY Asset ASC ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?php echo $objResuut["Asset"];?>"><?php echo $objResuut["Asset"];?></option>
<?php
}
?>
</select></td>
<td width="12%">รายละเอียด</td>
<td width="44%"><input name="txtName1" id="txtName1" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
<td valign="top">สาขา</td>
<td><input name="txtBrance" id="txtBrance" type="text" disabled="disabled" value="" size="25"/></td>
<td>ชั้น</td>
<td><input name="txtFloor" id="txtFloor" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
<td valign="top">ประเภทงาน</td>
<td colspan="3"><font id="typedevice2" color="red">
<select name="JobType" id="JobType" class="chosen-select" style="width:200px;" tabindex="2">
<option value="0">== กรุณาเลือก ==</option>
<option value="1">แจ้งโอนย้าย</option>
<option value="2">แจ้งชำรุด</option>
<option value="3">แจ้งสูญหาย</option>
</select>
</font></td>
</tr>
<tr>
<td valign="top">หมายเหตุ</td>
<td colspan="3"><textarea name="req_detail" id="req_detail" cols="45" rows="6" ></textarea></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr bgcolor="#999999">
<td colspan="4"><div align="center">ผู้รับงาน</div></td>
</tr>
<tr>
<td>ชื่อ - สกุล </td>
<td colspan="3"><select name="user_code" id="user_code" class="chosen-select" style="width:100px;" tabindex="2" OnChange="resutNameID(this.value);">
<option value="">== รหัส ==</option>
<?
mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_select_db("dbhelpcrm");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQLID ="select * from user inner join dep on ref_dep_id = dep_id";
$objQueryID = mysql_query($strSQLID);
while($objResuutID = mysql_fetch_array($objQueryID))
{
?>
<option value="<?php echo $objResuutID["user_code"];?>"><?php echo $objResuutID["user_code"];?></option>
<?php
}
?>
</select>
<input name="fname1" id="fname1" type="text" disabled="disabled" value="" size="20"/>
<input name="lname1" id="lname1" type="text" disabled="disabled" value="" size="20"/></td>
</tr>
<tr>
<td>อีเมล์</td>
<td colspan="3"><input name="email1" id="email1" disabled="disabled"type="text" value="" size="25"/></td>
</tr>
<tr>
<td>แผนก</td>
<td colspan="3"><input name="dep1" id="dep1" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
<td>เบอร์โทร</td>
<td colspan="3"><input name="tel1" id="tel1" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
<td>สาขา</td>
<td><font id="itemcode" color="red">
</font><font color="red">
<select name="Location" size="1" class="chosen-select" id="Location" style="width:200px;" tabindex="2">
<option value="">== กรุณาเลือกสาขา ==</option>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL ="select * from location ORDER BY LocationID ASC ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?php echo $objResuut["LocationName"];?>"><?php echo $objResuut["LocationName"];?></option>
<?php
}
?>
</select>
</font></td>
<td>ชั้น</td>
<td><input name="lname8" type="text" value="" size="25"/></td>
</tr>
<tr>
<td valign="top">หมายเหตุ</td>
<td colspan="3"><textarea name="detail2" cols="45" rows="6" ></textarea></td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td> </td>
<td colspan="3"><input type="submit" name="submit" value="บันทึก" />
<input type="reset" name="reset" value="ยกเลิก" /></td>
</tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="select/chosen.jquery.js" type="text/javascript"></script>
<script src="select/docsupport/prism.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
</script>
</form>
<br>
</body>
</html>
หน้า req.php รับค่าทดสอบ
Code (PHP)
<?php
echo '<div style="font-size:14px">';
echo '--------------------------------------------------------------------';
echo '<pre>';
echo '<b>แสดงค่าตัวแปร id</b>', "\n";
echo $_POST['req_curdate'], "\n";
echo '</pre>';
echo '--------------------------------------------------------------------';
echo '</div>';
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2017-03-14 01:25:36 |
By :
karurub |
View :
636 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้สามารถดึงข้อมูลมาแสดงได้บางช่อง ช่องที่มีการใช้ Script auto fill ไม่สามารถดึงข้อมูลมาแสดงได้ ต้องทำยังไงครับ
Script Auto fill ที่เอามาใช้ select ข้อมูล
Code (JavaScript)
<script language="JavaScript">
function resutName(Asset)
{
switch(Asset)
{
<?php
mysql_connect("localhost","root","1234") or die(mysql_error());
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL2 = "SELECT * FROM asset";
$objQuery2 = mysql_query($strSQL2);
while($objResult2 = mysql_fetch_array($objQuery2))
{
$AssetName = trim($objResult2["AssetName"]);
$req_AssetName = str_replace('"','',$AssetName);
$req_Brance = trim($objResult2["Location"]);
$req_Floor = trim($objResult2["Area"]);
?>
case "<?php echo trim($objResult2["Asset"]);?>":
form1.txtName1.value = "<?php echo $req_AssetName;?>";
form1.txtBrance.value = "<?php echo $req_Brance;?>";
form1.txtFloor.value = "<?php echo $req_Floor ?>";
break;
<?php
}
?>
default:
form1.txtName1.value = "";
form1.txtBrance.value = "";
form1.txtFloor.value = "";
}
}
</script>
ส่วนของการ selec ข้อมูลจาก DB แล้วให้ textbox ที่กำหนดจาก script ด้านบนให้แสดงข้อมูล auto
Code (PHP)
<tr>
<td>รหัสทรัพย์สิน</td>
<td width="28%"><select name="req_Asset" id="req_Asset" class="chosen-select" style="width:150px;" tabindex="2" OnChange="resutName(this.value);">
<option value="">== รหัสทรัพย์สิน ==</option>
<?
mysql_connect("localhost","root","1234");
mysql_select_db("asset");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL ="select * from asset ORDER BY Asset ASC ";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?php echo $objResuut["Asset"];?>"><?php echo $objResuut["Asset"];?></option>
<?php
}
?>
</select></td>
<td width="12%">รายละเอียด</td>
<td width="44%"><input name="txtName1" id="txtName1" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
<td valign="top">สาขา</td>
<td><input name="txtBrance" id="txtBrance" type="text" disabled="disabled" value="" size="25"/></td>
<td>ชั้น</td>
<td><input name="txtFloor" id="txtFloor" type="text" disabled="disabled" value="" size="25"/></td>
</tr>
<tr>
|
ประวัติการแก้ไข 2017-03-14 05:10:45 2017-03-14 05:11:59 2017-03-14 05:12:02
|
|
|
|
Date :
2017-03-14 05:08:36 |
By :
karurub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|