|
|
|
(php mysql) list menu ที่ สอง..........ยังไม่เปลี่ยนอ้ะค้ะ |
|
|
|
|
|
|
|
menu(PHP)
<?php
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("motor");
@mysql_query("SET NAMES UTF8");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language = "JavaScript">
//**** List Class (Start) ***//
function ListClass(SelectValue)
{
frmMain.ddlClass.length = 0
frmMain.ddlType.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlClass.options[frmMain.ddlClass.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM class ORDER BY class_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["brand_id"];?>;
strValue = "<?=$objResult["class_id"];?>";
strItem = "<?=$objResult["class_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.ddlClass.options[frmMain.ddlClass.length]= myOption
}
<?
}
?>
}
//**** List Class (End) ***//
//**** List Type (Start) ***//
function ListType(SelectValue)
{
frmMain.ddlType.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlType.options[frmMain.ddlType.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM type ORDER BY type_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["class_id"];?>;
strValue = "<?=$objResult["type_id"];?>";
strItem = "<?=$objResult["type_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.ddlType.options[frmMain.ddlType.length]= myOption
}
<?
}
?>
}
//**** List Type (End) ***//
</script>
</head>
<form name="frmMain" action="" method="post">
brand
<select id="ddlBrand" name="ddlBrand" onChange = "ListClass(this.value)">
<option selected value=""></option>
<?
$strSQL = "SELECT * FROM brand ORDER BY brand_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["brand_id"];?>"><?=$objResult["brand_name"];?></option>
<?
}
?>
</select>
claa
<select id="ddlClass" name="ddlClass" style="width:120px" onChange = "ListType(this.value)"></select>
type
<select id="ddlType" name="ddlType" style="width:200px"></select>
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
listmenu ที่สองมันยังไม่เปลี่ยนอ้ะค้ะ
Tag : PHP
|
|
|
|
|
|
Date :
2013-04-18 15:03:23 |
By :
lookpla26 |
View :
880 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|