|
|
|
ช่วยดูโค้ด เกี่ยวกับ listmenu ให้หน่อยคะ ไม่รู้แก้โค้ดผิดตรงไหน level สุดท้ายมันไม่ออกน่ะคะมี 3 table |
|
|
|
|
|
|
|
ไม่รู้แก้โค้ดผิดตรงไหน level สุดท้ายมันไม่ออกน่ะคะ
มี 3 table คือ
category>>category_id,category_name;
subcategory>>subcate_id,subcatename;
product_type>>protype_id,protype_name,subcate_id
Code (PHP)
<?php
<?
include('config.inc.php');
include('function.php');
//session_start();
connect_db($hostname,$user,$passwd);
$db=mysql_select_db($dbname);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>ThaiCreate.Com ListMenu</title>
<SCRIPT language=JavaScript1.2>
//**** List subcategory (Start) ***//
function Listsubcate(SelectValue)
{
frmMain.ddlsubcate.length = 0
frmMain.ddlprotype.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlsubcate.options[frmMain.ddlsubcate.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM subcategory ORDER BY subcate_id ASC ";
$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["category_id"];?>;
strValue = "<?=$objResult["subcate_id"];?>";
strItem = "<?=$objResult["subcate_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.ddlsubcate.options[frmMain.ddlsubcate.length]= myOption
}
<?
}
?>
}
//**** List subcategory (End) ***//
//**** Listprotype (Start) ***//
function Listprotype(SelectValue)
{
frmMain.ddlprotype.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlprotype.options[frmMain.ddlprotype.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM product_type ORDER BY protype_id ASC ";
$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["subcate_id"];?>;
strValue = "<?=$objResult["protype_id"];?>";
strItem = "<?=$objResult["protype_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.ddlprotype.options[frmMain.ddlprotype.length]= myOption
}
<?
}
?>
}
//**** List protype (End) ***//
</script>
</head>
<form name="frmMain" action="" method="post">
category
<select id="ddlcate" name="ddlcate" onChange = "Listsubcate(this.value)">
<option selected value=""></option>
<?
$strSQL = "SELECT * FROM category ORDER BY category_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["category_id"];?>"><?=$objResult["category_name"];?></option>
<?
}
?>
</select>
subcategory
<select id="ddlsubcate" name="ddlsubcate" style="width:120px" onChange = "Listprotype(this.value)"></select>
Product type
<select id="ddlprotype" name="ddlprotype" style="width:200px"></select>
</form>
</body>
</html>
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-07-19 00:24:25 |
By :
sayo |
View :
855 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดูแล้วนะครับ ทำไงต่อครับ
|
|
|
|
|
Date :
2009-07-19 09:41:23 |
By :
darffyplanet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list menu ชั้นสุดท้าย Protype มันไม่ขึ้นน่ะคะ
|
|
|
|
|
Date :
2009-07-19 20:51:57 |
By :
sayo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|