|
 |
|
จากวิธีการสร้าง Dependent ListMenu เลือกข้อมูลหลักและข้อมูลย่อยเปลี่ยนตามหัวข้อหลัก |
|
 |
|
|
 |
 |
|
โค้ดของผมนะครับ ผมลองทำแค่ 2 ขั้นก่อน แต่ว่า
Code (PHP)
<?php
include("../db_conn.inc.php");
?>
<!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>
<link href="style/style.css" rel="stylesheet" type="text/css">
<script language="javascript">
//ClassName (start)
function ListClass(value)
{
formSearch.selClass.length = 0;
//formSearch.selTerm.length = 0;
//insert null default value
var myOption = new Option('','');
formSearch.selClass.options[formSearch.selClass.length]=myOption;
<?php
$sql = "select * from dbo_tbreportscheduleclass order by ClassID asc ;";
$query = mysql_query($sql)or die(mysql_error());
$intRows = 0;
while($result = mysql_fetch_array($query))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$result["GroupsName"];?>;//SelGroup
strValue = <?=$result["ClassID"];?>;
strItem = <?=$result["ClassName"];?>;
mySubList[x,0]=strItem;
mySubList[x,1]=strGroup;
mySubList[x,2]=strValue;
if(mySubList[x,1] == value)
{
var myOption = new Option(mySubList[x,0], mySubList[x,2]);
formSearch.selClass.options[formSearch.selClass.length]=myOption;
}
<?php
}
?>
}
</script>
</head>
<body>
<h3 align="center">ค้นหาตารางเรียน</h3>
<form id="formSearch" name="formSearch" class="cssform1" method="post" action="">
<p><label for="selGroup">กลุ่มเรียน : </label>
<select name="selGroup" id="selGroup" onchange="ListClass(this.value)">
<option selected="selected" value="">-----โปรดเลือก-----</option>
<?php
$sql = "select distinct(GroupsName) from dbo_tbreportscheduleclass order by GroupsName asc;";
$query = mysql_query($sql)or die(mysql_error());
while($result = mysql_fetch_assoc($query))
{
?>
<option value="<?=$result["GroupsName"];?>"><?=$result["GroupsName"];?></option>
<?php
}
?>
</select>
</p>
<p>
<label for="selClass">ห้องเรียน : </label>
<select name="selClass" id="selClass">
</select>
</p>
</form>
</body>
</html>
select list ห้องเรียนไม่ออกอ่ะครับ อันที่สอง
ผมทำตรงไหนพลาดหรือเปล่า

Tag : PHP, MySQL, JavaScript

|
|
 |
 |
 |
 |
Date :
2014-02-13 13:59:14 |
By :
angelkiller9 |
View :
987 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 02
|