ช่วยดู code select list menu ชั้นที่ 4 ด้วยครับไม่รู้ว่าผิดตรงไหน list menu 1 2 3 ขึ้นปกติ แต่ตัวที่ 4 Center ไม่ขึ้นครับ
Code (PHP)
//**** List Province (Start) ***//
function ListProvince(SelectValue)
{
document.frmMain.ddlProvince.length = 0
document.frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
document.frmMain.ddlProvince.options[document.frmMain.ddlProvince.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM tb_province ORDER BY province_ID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = <?php echo $objResult["geo_ID"];?>;
strValue = "<?php echo $objResult["province_ID"];?>";
strItem = "<?php echo $objResult["province_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])
document.frmMain.ddlProvince.options[document.frmMain.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
document.frmMain.ddlAmphur.length = 0
document.frmMain.ddlCenter.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
document.frmMain.ddlAmphur.options[document.frmMain.ddlAmphur.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM tb_amper ORDER BY amper_ID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = <?php echo $objResult["province_ID"];?>;
strValue = "<?php echo $objResult["amper_ID"];?>";
strItem = "<?php echo $objResult["amper_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])
document.frmMain.ddlAmphur.options[document.frmMain.ddlAmphur.length]= myOption
}
<?
}
?>
}
//**** List Amphur (End) ***//
//**** List Center (Start) ***//
function ListCenter(SelectValue)
{
document.frmMain.ddlCenter.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
document.frmMain.ddlCenter.options[document.frmMain.ddlCenter.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM tb_center ORDER BY center_ID ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intRows = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$intRows++;
?>
x = <?php echo $intRows;?>;
mySubList = new Array();
strGroup = <?php echo $objResult["amper_ID"];?>;
strValue = "<?php echo $objResult["center_ID"];?>";
strItem = "<?php echo $objResult["center_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])
document.frmMain.ddlCenter.options[document.frmMain.ddlCenter.length]= myOption
}
<?
}
?>
}
//**** List Center (End) ***//
Tag : PHP, JavaScript
Date :
2012-06-20 17:47:53
By :
benservice
View :
1204
Reply :
10
ถ้า Group เป็น string ให้ใส่ "" ด้วยครับ เช่น
Code (JavaScript)
strGroup = "<?php echo $objResult["amper_ID"];?>";
Date :
2012-06-20 19:15:35
By :
mr.win
ลอง View Source ในหน้า Web Browser มาให้หน่อยครับ
Date :
2012-06-21 11:17:48
By :
mr.win
tb_center กับ tb_amper ขอดูฐานข้อมูลทีครับ
Date :
2012-06-21 11:29:09
By :
heezui
ตอบความคิดเห็นที่ : 4 เขียนโดย : heezui เมื่อวันที่ 2012-06-21 11:29:09
รายละเอียดของการตอบ ::
อันนี้ เทเบิล amper ครับ
amper
CREATE TABLE `tb_amper` (
`amper_ID` int(5) NOT NULL auto_increment,
`amper_Code` varchar(4) collate utf8_unicode_ci NOT NULL,
`amper_Name` varchar(150) collate utf8_unicode_ci NOT NULL,
`amper_Name_Eng` varchar(150) collate utf8_unicode_ci NOT NULL,
`geo_ID` int(5) NOT NULL default '0',
`province_ID` int(5) NOT NULL default '0',
PRIMARY KEY (`amper_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=999 ;
ส่วนอันนี้เทเบิล center
center
CREATE TABLE `tb_center` (
`center_ID` int(11) NOT NULL auto_increment,
`center_Name` varchar(150) NOT NULL,
`address` varchar(7) NOT NULL,
`moo` varchar(30) NOT NULL,
`ban` varchar(30) NOT NULL,
`tambon` varchar(30) NOT NULL,
`amper_ID` varchar(7) NOT NULL,
`province_ID` varchar(7) NOT NULL,
`geo_ID` int(7) NOT NULL,
`zip` varchar(5) NOT NULL,
`cellphone` varchar(15) NOT NULL,
`building_Date` varchar(30) NOT NULL,
`latitude` varchar(30) NOT NULL,
`longitude` varchar(30) NOT NULL,
PRIMARY KEY (`center_ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=73 ;
Date :
2012-06-21 11:40:27
By :
benservice
Good job
Date :
2012-06-21 12:53:12
By :
mr.win
Load balance : Server 00