|
|
|
เกี่ยวกับ dependent List ค่ะ คือตอนนี้ข้อมูลใน list มันไม่ขึ้นทั้งสองอันเลยอะค่ะ เปนเพราะอะไร |
|
|
|
|
|
|
|
คือตอนนี้ข้อมูลใน list มันไม่ขึ้นทั้งสองอันเลยอะค่ะ เปนเพราะอะไร คะ เด๊ยวเอาโค้ดให้ดูนะคะ
โค้ดนี้ประยุกต์มาจาก https://www.thaicreate.com/free-web-script/dependent-listmenu-dropdownlist.html
<?php
$db_hostname="localhost";
$db_username="root";
$db_password="1234";
$db_name="myproject";
$connect=mysql_connect($db_hostname,$db_username,$db_password)or die("Not connect database");
mysql_select_db($db_name) or die("เลือกฐานข้อมูลไม่ได้");
mysql_query("SET NAMES UTF8");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ThaiCreate.Com ListMenu</title>
<script language = "JavaScript">
//**** List Database (Start) ***//
function ListDatabase(SelectValue)
{
frmMain.ddlDatabase.length = 0
frmMain.ddlExerciseSet.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlDatabase.options[frmMain.ddlDatabase.length]= myOption
<?
session_start();
$proID=$_SESSION[username];
$intRows = 0;
$strSql = "SELECT * FROM database_info WHERE proID='$proID'";
$objQuery = mysql_query($strSql) or die ("Error Query [".$strSql."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
//strGroup = <?=$objResult["GEO_ID"];?>;
strValue = "<?=$objResult["dbID"];?>";
strItem = "<?=$objResult["dbName"];?>";
mySubList[x,0] = strItem;
//mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlDatabase.options[frmMain.ddlDatabase.length]= myOption
}
<?
}
?>
}
//**** List Database (End) ***//
//**** List ExerciseSet (Start) ***//
function ListExerciseSet(SelectValue)
{
frmMain.ddlExerciseSet.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlExerciseSet.options[frmMain.ddlExerciseSet.length]= myOption
<?
$intRows = 0;
$strSql = "SELECT * FROM exercise_set";
$objQuery = mysql_query($strSql) or die ("Error Query [".$strSql."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["dbID"];?>;
strValue = "<?=$objResult["setID"];?>";
strItem = "แบบฝึกหัดชุดที่ <?=$objResult["setID"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
frmMain.ddlExerciseSet.options[frmMain.ddlExerciseSet.length]= myOption
}
<?
}
?>
}
//**** List ExerciseSet (End) ***//
</script>
</head>
<form name="frmMain" action="" method="post">
Database
<select id="ddlDatabase" name="ddlDatabase" onChange = "ListExerciseSet(this.value)">
<option>-------เลือกฐานข้อมูล---------</option>
</select>
Exercise Set
<select id="ddlExerciseSet" name="ddlExerciseSet">
<option>-------เลือกชุดแบบฝึกหัด----------</option>
</select>
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-12-08 23:42:17 |
By :
independence55 |
View :
1193 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
งือๆ ช่วยหนูหน่อยน้าาาา
|
|
|
|
|
Date :
2009-12-09 01:17:02 |
By :
independence55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
multilevel combobox จังหวัด อำเภอ ตำบล php และ asp.net (c#)
http://cakephp.jitwitya.com/post/jquery-multilevel-combobox
http://www.ziddu.com/download/7660090/jquery-multilevel-combobox-php.zip.html
http://www.ziddu.com/download/7432325/jquery-multilevel-combobox-asp.net.zip.html
|
|
|
|
|
Date :
2009-12-09 09:10:01 |
By :
num |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุนมากนะคะ เด๊ยวจะไปศึกษาดูค่ะ
|
|
|
|
|
Date :
2009-12-09 10:36:04 |
By :
independence55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|