|
|
|
ทำ depen dropdownlist แล้วไม่ขึ้นอ่ะครับ ใช้ Access ODBC |
|
|
|
|
|
|
|
ผมลองเอามาทำโดยผ่าน ODBC แต่ทำไมถึงไม่ติดอ่ะครับ ผมพลาดตรงไหนช่วยดูให้หน่อยครับ
Code (PHP)
<?php
$objConnect = odbc_connect("mydatabase","","") or die("Error Connect to Database");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<script src="datetime/datetimepicker_css.js"></script>
<script language = "JavaScript">
//**** List Province (Start) ***//
function ListAmphur(SelectValue)
{
frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM amphur ORDER BY AMPHUR_ID ASC ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
$intRows = 0;
while($objResult = odbc_fetch_array($objExec))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["PROVINCE_ID"];?>;
strValue = "<?=$objResult["AMPHUR_ID"];?>";
strItem = "<?=$objResult["AMPHUR_NAME"];?>";
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.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
}
<?
}
?>
}
/////////////////////////////////////////////////////
function ListDis(SelectValue)
{
frmMain.ddlDistrict.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlDistrict.options[frmMain.ddlDistrict.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM district ORDER BY DISTRICT_ID ASC ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
echo $strSQL;
$intRows = 0;
while($objResult = odbc_fetch_array($objExec))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResult["AMPHUR_ID"];?>;
strValue = "<?=$objResult["DISTRICT_ID"];?>";
strItem = "<?=$objResult["DISTRICT_NAME"];?>";
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.ddlDistrict.options[frmMain.ddlDistrict.length]= myOption
}
<?
}
?>
}
//**** List Amphur (End) ***//
</script>
</head>
<form method="post" action="frmMain">
<table>
<tr>
<td align="right">จังหวัด</td>
<td>
<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange = "ListAmphur(this.value)">
<option selected value="">กรุณาเลือก</option>
<?
$strSQL = "SELECT * FROM province ORDER BY PROVINCE_ID ASC ";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
while($objResult = odbc_fetch_array($objExec))
{
?>
<option value="<?=$objResult["PROVINCE_ID"];?>"><?=$objResult["PROVINCE_NAME"];?></option>
<?
}
?>
</select>
</td>
</tr>
<tr>
<td align="right">เขต</td>
<td>
<select id="ddlAmphur" name="ddlAmphur" style="width:200px" onChange = "ListDis(this.value)">
<option selected value="">กรุณาเลือก</option>
</select>
</td>
</tr>
<tr>
<td align="right">แขวง</td>
<td>
<select id="ddlDistrict" name="ddlDistrict" style="width:200px">
<option selected value="">กรุณาเลือก</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
</table>
<form>
Tag : PHP, Ms Access, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2013-04-01 15:43:44 |
By :
Clamore |
View :
750 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง View Source ในหน้า Web Browser ดูครับ มันมี Error หรือเปล่า ?
|
|
|
|
|
Date :
2013-04-01 17:10:40 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มัน viewsource ไม่ได้เลยอ่ะครับ มันค้างไปเลยพอ viewsource
|
|
|
|
|
Date :
2013-04-02 20:01:15 |
By :
Clamore |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-04-03 09:09:29 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|