จากหัวข้อข้างบนเลยครับ คือผมทำ listbox 2 ชั้นแล้วเลือกชั้นที่สองให้ include อีกหน้ามาแสดงข้างของlistbox ตามvalueใน db อะครับตอนนี้ทำได้แค่เปลี่ยนหน้า เลยไม่ทราบว่าจะต้อง if ยังไงให้ include เข้ามาโดย valuelistboxยังอยู่โดยไม่ต้องรีเฟชหน้าอะคับ
ตัวอย่างโค๊ดครับ
<? include("includes/config.inc.php");
$subID =$_REQUEST["subID"];
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8">
<title>Main</title>
<style type="text/css">
.head {
font-family: MS Sans Serif;font-size: 18px;
color :#ffffff;
}
td,th {
font-family: MS Sans Serif;font-size: 17px;
color :#606060;
border: 1px solid #dddddd;
padding: 1px;
}
.hand_new{
cursor: hand;}
body,td,th {
color: #000000;
font-size: 14px;
}
table {
border-collapse: collapse;
}
h1 {
font-size: 16px;
font-family: MS Sans Serif;
}
.center {
text-align: center;
body { margin: 5px 0px; padding: 0px 0px}
}
</style>
<style type="text/css">
.mylabel{
display: inline-block;
width: 150px;
margin-bottom: 10px;
}
</style>
<?
// $HrSessLogin = $_SESSION["HrSessLogin"];
$SessLogin = '530841';
$sql_Employee = "SELECT * FROM Employee where EmpID='$SessLogin'";
$result_Employee = $db_tm->sql_query($sql_Employee);
$rows_Employee = $db_tm-> sql_fetchrow($result_Employee);
$sql_Position = "SELECT * FROM Master_Position where MainPositionID='$rows_Employee[MainPositionID]'";
$result_Position = $db_tm->sql_query($sql_Position);
$rows_Position = $db_tm-> sql_fetchrow($result_Position);
$sql_Division = "SELECT * FROM Master_Division where Division_Code='$rows_Employee[Division_Code]'";
$result_Division = $db_tm->sql_query($sql_Division);
$rows_Division = $db_tm-> sql_fetchrow($result_Division);
$sql_Department = "SELECT * FROM Master_Department where Department_Code ='$rows_Employee[Department_Code]'";
$result_Department = $db_tm->sql_query($sql_Department);
$rows_Department = $db_tm-> sql_fetchrow($result_Department);
$EmpID =$rows_Employee["EmpID"];
$EmpLName =$rows_Employee["EmpLName"];
$EmpName =$rows_Employee["EmpName"];
$MoblieContact =$rows_Employee["MoblieContact"];
$Division_TLongName =$rows_Division["Division_TLongName"];
$Department_TLongName =$rows_Department["Department_TLongName"];
$Position_Name =$rows_Position["Position_Name"];
$EmpName= iconv("tis-620", "utf-8", $EmpName);
$EmpLName = iconv("tis-620", "utf-8", $EmpLName);
$Division_TLongName = iconv("tis-620", "utf-8", $Division_TLongName);
$Department_TLongName = iconv("tis-620", "utf-8", $Department_TLongName);
$Position_Name = iconv("tis-620", "utf-8", $Position_Name);
?>
</head>
<body >
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr height="35" bgcolor="#f7f7f7" font face = "MS Sans Serif" >
<td colspan="10" bgcolor="#f7f7f7" scope="col"> การยื่นคำร้องและสถานะ /ใบคำร้อง / แจ้งปัญหา / แก้ไขข้อมูล</td>
</tr>
<tr height="1" bgcolor="#00000">
<td ></td>
</tr>
</table><br>
<form name="Problem1" enctype="multipart/form-data" method="post" action="insert_med.php">
<table border="0" width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><h1>ข้อมูลพนักงาน</h1></td>
</tr>
<tr>
<td>
<table border="0" width="100%" align="left" cellpadding="0" cellspacing="0" >
<tr>
<td>รหัสพนักงาน</td>
<td colspan="3" >
<input type='text'name="customerID"value="<?echo$EmpID;?>">
</td>
</tr>
<tr>
<td>ชื่อ-นามสกุล</td>
<td colspan="3"><?echo$EmpName;?> <?echo$EmpLName;?></td>
</tr>
<tr>
<td width="25%">ตำแหน่ง</td>
<td width="25%"><?echo$Position_Name;?></td>
<td width="15%">กอง</td>
<td width="35%"><?echo$Department_TLongName;?></td>
</tr>
<tr>
<td width="25%">ฝ่าย</td>
<td width="25%"><?echo$Division_TLongName;?></td>
<td width="15%">เบอร์โทรศัพท์</td>
<td width="35%"><?echo$MoblieContact;?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><h1>ข้อมูลระบบงานที่ต้องการแจ้งปัญหา</h1></td>
</tr>
<tr>
<td>
<table border="0" width="100%" align="left" cellpadding="0" cellspacing="0" >
<tr>
<td>ชื่อระบบงานหลัก</td>
<td colspan="3">
<span>
<select onchange="onchangedata(this)" name="ProjectMNo">
<option value="0">== กรุณาเลือกระบบงานหลัก ==</option>
<?
$sql_SITAP1= "SELECT * FROM Projects";
$result_SITAP1=$db_tm->sql_query($sql_SITAP1);
$count_SITAP1= $db_tm->sql_numrows($result_SITAP1);
$rows_SITAP1=$db_tm->sql_fetchrow($result_SITAP1);
for($i_SITAP1=1 ; $i_SITAP1<=$count_SITAP1 ; $i_SITAP1++){
?>
<option value="<? echo $rows_SITAP1['ProjID']?>"<?if($rows_SITAP1['ProjID']==$subID){echo"selected";}?>><?echo iconv('TIS-620','UTF-8',($rows_SITAP1['ProjName']));?></option><br>
<? $rows_SITAP1 = $db_tm->sql_fetchrow($result_SITAP1);
}
?>
</select>
</span>
</td>
</tr>
<tr>
<td>ชื่อระบบงานย่อย</td>
<td colspan="3">
<span >
<select onchange="onchangedataSub(this)" name="ProjectSNo" >
<option value="0">== กรุณาเลือกระบบงานย่อย ==</option>
<?
$sql_HR= "SELECT * FROM SubProjects where ProjID='$subID' ";
$result_HR=$db_tm->sql_query($sql_HR);
$count_HR= $db_tm->sql_numrows($result_HR);
$rows_HR=$db_tm->sql_fetchrow($result_HR);
for($i_HR=1 ; $i_HR<=$count_HR ; $i_HR++){
?>
<option value="<? echo $rows_HR['SubProjID']?>"><?echo iconv('TIS-620','UTF-8',($rows_HR['SubProjName']));?></option><br>
<? $rows_HR = $db_tm->sql_fetchrow($result_HR);
}
?>
</select>
</span>
</td>
</tr>
<tr>
<td>หัวข้อปัญหาที่แจ้ง</td>
<?
if($rows_HR['SubProjID']==1) {
include("index.php?MM=11");
}else if($rows_HR['SubProjID']==16) {
include("index.php?MM=16");
}
?>
<td colspan="3"><input type="text" name="HeadQuestion">**ใช้เป็นหัวข้อในการส่ง E-mail 40 ตัวอักษร**</td>
</tr>
<tr>
<td>รายละเอียดของปัญหา</td>
<td colspan="3">
</tr>
<tr>
<td>เอกสารแนบ</td>
<td colspan="3">
<?
$folder="filepdf/"; // กำหนดโฟลเดอร์ที่จะเก็บ
?>
<input type="file" name = "myfile"style="border:0px;"/>**ขนาดของไฟล์ไม่เกิน 2 Mb. กรุณาตรวจสอบด้วย **</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><button type="button" name="button1" onclick="ITAPSubmit();"><img src="images/save.png" width="16" height="16" align="absmiddle" /> บันทึก</button>
<button type="reset" name="button2"><img src="images/cancel.png" width="16" height="16" align="absmiddle" /> ไม่บันทึก</button></td>
</tr>
<tr height="10"bgcolor="#ffffff">
<td></td>
</tr>
</table>
</form>
</body>
</html>
<script>
function onchangedata(xx)
{window.location="index.php?MM=1&subID="+xx.value;
}
</script>
<script>
function onchangedataSub(xxx){
if(xxx.value=='1'){
window.location="index.php?MM=11";
}else if(xxx.value=='6'){
window.location="index.php?MM=16";
}
}
</script>
ขอความช่วยเหลือ php หน่อยครับ ใช้ listbox ดึงข้อมูลจาก dbพอเลือกแล้วให้ includeอีกหน้ามาแสดงข้างล่างโดยlistboxยังอยู่คับ
ตัวอย่างโค๊ดครับ
<? include("includes/config.inc.php");
$subID =$_REQUEST["subID"];
?>
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8">
<title>Main</title>
<style type="text/css">
.head {
font-family: MS Sans Serif;font-size: 18px;
color :#ffffff;
}
td,th {
font-family: MS Sans Serif;font-size: 17px;
color :#606060;
border: 1px solid #dddddd;
padding: 1px;
}
.hand_new{
cursor: hand;}
body,td,th {
color: #000000;
font-size: 14px;
}
table {
border-collapse: collapse;
}
h1 {
font-size: 16px;
font-family: MS Sans Serif;
}
.center {
text-align: center;
body { margin: 5px 0px; padding: 0px 0px}
}
</style>
<style type="text/css">
.mylabel{
display: inline-block;
width: 150px;
margin-bottom: 10px;
}
</style>
<?
// $HrSessLogin = $_SESSION["HrSessLogin"];
$SessLogin = '530841';
$sql_Employee = "SELECT * FROM Employee where EmpID='$SessLogin'";
$result_Employee = $db_tm->sql_query($sql_Employee);
$rows_Employee = $db_tm-> sql_fetchrow($result_Employee);
$sql_Position = "SELECT * FROM Master_Position where MainPositionID='$rows_Employee[MainPositionID]'";
$result_Position = $db_tm->sql_query($sql_Position);
$rows_Position = $db_tm-> sql_fetchrow($result_Position);
$sql_Division = "SELECT * FROM Master_Division where Division_Code='$rows_Employee[Division_Code]'";
$result_Division = $db_tm->sql_query($sql_Division);
$rows_Division = $db_tm-> sql_fetchrow($result_Division);
$sql_Department = "SELECT * FROM Master_Department where Department_Code ='$rows_Employee[Department_Code]'";
$result_Department = $db_tm->sql_query($sql_Department);
$rows_Department = $db_tm-> sql_fetchrow($result_Department);
$EmpID =$rows_Employee["EmpID"];
$EmpLName =$rows_Employee["EmpLName"];
$EmpName =$rows_Employee["EmpName"];
$MoblieContact =$rows_Employee["MoblieContact"];
$Division_TLongName =$rows_Division["Division_TLongName"];
$Department_TLongName =$rows_Department["Department_TLongName"];
$Position_Name =$rows_Position["Position_Name"];
$EmpName= iconv("tis-620", "utf-8", $EmpName);
$EmpLName = iconv("tis-620", "utf-8", $EmpLName);
$Division_TLongName = iconv("tis-620", "utf-8", $Division_TLongName);
$Department_TLongName = iconv("tis-620", "utf-8", $Department_TLongName);
$Position_Name = iconv("tis-620", "utf-8", $Position_Name);
?>
</head>
<body >
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr height="35" bgcolor="#f7f7f7" font face = "MS Sans Serif" >
<td colspan="10" bgcolor="#f7f7f7" scope="col"> การยื่นคำร้องและสถานะ /ใบคำร้อง / แจ้งปัญหา / แก้ไขข้อมูล</td>
</tr>
<tr height="1" bgcolor="#00000">
<td ></td>
</tr>
</table><br>
<form name="Problem1" enctype="multipart/form-data" method="post" action="insert_med.php">
<table border="0" width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><h1>ข้อมูลพนักงาน</h1></td>
</tr>
<tr>
<td>
<table border="0" width="100%" align="left" cellpadding="0" cellspacing="0" >
<tr>
<td>รหัสพนักงาน</td>
<td colspan="3" >
<input type='text'name="customerID"value="<?echo$EmpID;?>">
</td>
</tr>
<tr>
<td>ชื่อ-นามสกุล</td>
<td colspan="3"><?echo$EmpName;?> <?echo$EmpLName;?></td>
</tr>
<tr>
<td width="25%">ตำแหน่ง</td>
<td width="25%"><?echo$Position_Name;?></td>
<td width="15%">กอง</td>
<td width="35%"><?echo$Department_TLongName;?></td>
</tr>
<tr>
<td width="25%">ฝ่าย</td>
<td width="25%"><?echo$Division_TLongName;?></td>
<td width="15%">เบอร์โทรศัพท์</td>
<td width="35%"><?echo$MoblieContact;?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><h1>ข้อมูลระบบงานที่ต้องการแจ้งปัญหา</h1></td>
</tr>
<tr>
<td>
<table border="0" width="100%" align="left" cellpadding="0" cellspacing="0" >
<tr>
<td>ชื่อระบบงานหลัก</td>
<td colspan="3">
<span>
<select onchange="onchangedata(this)" name="ProjectMNo">
<option value="0">== กรุณาเลือกระบบงานหลัก ==</option>
<?
$sql_SITAP1= "SELECT * FROM Projects";
$result_SITAP1=$db_tm->sql_query($sql_SITAP1);
$count_SITAP1= $db_tm->sql_numrows($result_SITAP1);
$rows_SITAP1=$db_tm->sql_fetchrow($result_SITAP1);
for($i_SITAP1=1 ; $i_SITAP1<=$count_SITAP1 ; $i_SITAP1++){
?>
<option value="<? echo $rows_SITAP1['ProjID']?>"<?if($rows_SITAP1['ProjID']==$subID){echo"selected";}?>><?echo iconv('TIS-620','UTF-8',($rows_SITAP1['ProjName']));?></option><br>
<? $rows_SITAP1 = $db_tm->sql_fetchrow($result_SITAP1);
}
?>
</select>
</span>
</td>
</tr>
<tr>
<td>ชื่อระบบงานย่อย</td>
<td colspan="3">
<span >
<select onchange="onchangedataSub(this)" name="ProjectSNo" >
<option value="0">== กรุณาเลือกระบบงานย่อย ==</option>
<?
$sql_HR= "SELECT * FROM SubProjects where ProjID='$subID' ";
$result_HR=$db_tm->sql_query($sql_HR);
$count_HR= $db_tm->sql_numrows($result_HR);
$rows_HR=$db_tm->sql_fetchrow($result_HR);
for($i_HR=1 ; $i_HR<=$count_HR ; $i_HR++){
?>
<option value="<? echo $rows_HR['SubProjID']?>"><?echo iconv('TIS-620','UTF-8',($rows_HR['SubProjName']));?></option><br>
<? $rows_HR = $db_tm->sql_fetchrow($result_HR);
}
?>
</select>
</span>
</td>
</tr>
<tr>
<td>หัวข้อปัญหาที่แจ้ง</td>
<?
if($rows_HR['SubProjID']==1) {
include("index.php?MM=11");
}else if($rows_HR['SubProjID']==16) {
include("index.php?MM=16");
}
?>
<td colspan="3"><input type="text" name="HeadQuestion">**ใช้เป็นหัวข้อในการส่ง E-mail 40 ตัวอักษร**</td>
</tr>
<tr>
<td>รายละเอียดของปัญหา</td>
<td colspan="3">
</tr>
<tr>
<td>เอกสารแนบ</td>
<td colspan="3">
<?
$folder="filepdf/"; // กำหนดโฟลเดอร์ที่จะเก็บ
?>
<input type="file" name = "myfile"style="border:0px;"/>**ขนาดของไฟล์ไม่เกิน 2 Mb. กรุณาตรวจสอบด้วย **</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><button type="button" name="button1" onclick="ITAPSubmit();"><img src="images/save.png" width="16" height="16" align="absmiddle" /> บันทึก</button>
<button type="reset" name="button2"><img src="images/cancel.png" width="16" height="16" align="absmiddle" /> ไม่บันทึก</button></td>
</tr>
<tr height="10"bgcolor="#ffffff">
<td></td>
</tr>
</table>
</form>
</body>
</html>
<script>
function onchangedata(xx)
{window.location="index.php?MM=1&subID="+xx.value;
}
</script>
<script>
function onchangedataSub(xxx){
if(xxx.value=='1'){
window.location="index.php?MM=11";
}else if(xxx.value=='6'){
window.location="index.php?MM=16";
}
}
</script>