|
 |
|
ช่วยดูโค้ด list menu ให้หน่อยครับ ว่าผิดตรงไหน ผมงง มากเลย ช่วยหน่อยนะครับผม |
|
 |
|
|
 |
 |
|
มันเป็นแบบนี้ครับ

|
 |
 |
 |
 |
Date :
2012-03-04 01:04:35 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
View Source ในหน้า IE มาให้หน่อยครับ 
|
 |
 |
 |
 |
Date :
2012-03-04 07:22:43 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี้ครับ พี่วิน
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>ThaiCreate.Com ListMenu</title>
<script language = "JavaScript">
function Listmovie(SelectValue)
{
frmMain.movie.length = 0
var myOption = new Option('','')
frmMain.movie.options[frmMain.movie.length]= myOption
x = 1;
mySubList = new Array();
strGroup = mn2;
strValue = "m001";
strItem = "บรรเลงฝัน บันดาลรัก";
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.movie.options[frmMain.movie.length]= myOption
}
x = 2;
mySubList = new Array();
strGroup = mn2;
strValue = "m002";
strItem = "โกสต์ ไรเดอร์ อเวจีพิฆาต";
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.movie.options[frmMain.movie.length]= myOption
}
x = 3;
mySubList = new Array();
strGroup = mn1;
strValue = "m003";
strItem = "รักทำนองนี้ ";
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.movie.options[frmMain.movie.length]= myOption
}
x = 4;
mySubList = new Array();
strGroup = mn2;
strValue = "m004";
strItem = "แจ็ค แอนด์ จิล";
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.movie.options[frmMain.movie.length]= myOption
}
x = 5;
mySubList = new Array();
strGroup = mn2;
strValue = "m005";
strItem = "ฝ่าฝูงเขี้ยวสยองโลก ";
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.movie.options[frmMain.movie.length]= myOption
}
x = 6;
mySubList = new Array();
strGroup = mn1;
strValue = "m006";
strItem = "รักสุดทีน ";
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.movie.options[frmMain.movie.length]= myOption
}
x = 7;
mySubList = new Array();
strGroup = mn1;
strValue = "m007";
strItem = "รักเอาอยู่ ";
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.movie.options[frmMain.movie.length]= myOption
}
x = 8;
mySubList = new Array();
strGroup = mn2;
strValue = "m008";
strItem = "จอมโจร สโนว์ไวท์ กับราชินีบานฉ่ำ";
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.movie.options[frmMain.movie.length]= myOption
}
x = 9;
mySubList = new Array();
strGroup = mn1;
strValue = "m009";
strItem = "407 เที่ยวบินผี";
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.movie.options[frmMain.movie.length]= myOption
}
x = 10;
mySubList = new Array();
strGroup = mn2;
strValue = "m010";
strItem = "สงครามหัวใจ คู่ระห่ำพยัคฆ์ร้าย";
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.movie.options[frmMain.movie.length]= myOption
}
x = 11;
mySubList = new Array();
strGroup = mn2;
strValue = "m011";
strItem = "The Good Doctor";
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.movie.options[frmMain.movie.length]= myOption
}
x = 12;
mySubList = new Array();
strGroup = mn2;
strValue = "m012";
strItem = "นักรบสงครามข้ามจักรวาล";
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.movie.options[frmMain.movie.length]= myOption
}
x = 13;
mySubList = new Array();
strGroup = mn1;
strValue = "m013";
strItem = "dsd";
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.movie.options[frmMain.movie.length]= myOption
}
x = 14;
mySubList = new Array();
strGroup = mn2;
strValue = "m014";
strItem = "sdfsf";
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.movie.options[frmMain.movie.length]= myOption
}
}
</script>
</head>
<form name="frmMain" action="" method="post">
โซนหนัง
<select id="nation" name="nation" onChange = "Listmovie(this.value)">
<option selected value=""></option>
<option value="mn1">หนังไทย</option>
<option value="mn2">หนังฝรั่ง</option>
<option value="mn3">หนังจีน</option>
<option value="mn4">หนังอินเดีย</option>
</select>
ชื่อหนัง
<select id="movie" name="movie" style="width:200px"></select>
</form>
</body>
</html>
|
ประวัติการแก้ไข 2012-03-04 13:20:53
 |
 |
 |
 |
Date :
2012-03-04 13:19:07 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยหน่อยนะครับ
|
 |
 |
 |
 |
Date :
2012-03-04 15:46:34 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดันๆๆๆๆ
|
 |
 |
 |
 |
Date :
2012-03-05 13:31:58 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอลิ้งตัวอย่างเดิมหน่อย
|
 |
 |
 |
 |
Date :
2012-03-05 13:47:08 |
By :
บังเอิญผ่านมาเห็น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
..................................
|
 |
 |
 |
 |
Date :
2012-03-05 21:30:37 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้วิธีนี้ไหม
Code (PHP)
เอาสคริปท์นี้ใว้ใน head
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
อันนี้เป็นตัวอย่างที่เราเอาใว้ใช้เป็นตัวอย่างน่ะ
หลักการทำงานคือ ถ้าเลือก option ตัวที่ต้องการแล้วมันจะทำส่งค่าเป็นแบบ get ทันที
ข้างล่างนี้คุณก็ใช้มันเป็น option อันแรก และส่วน option อันที่สอง คุณก็ให้มันรับค่าที่ส่งมาจาก option อันแรก
แล้วไปทำการ query ข้อมูลในเบสมาโชว์
<select name="ddlStockID" id="ddlStockID" onChange="MM_jumpMenu('parent',this,0)">
<option value="?StockID=">-- เลือกรายการวัตถุดิบสินค้า --</option>
<?
$i=0;
$query=mysql_query("select * from stock where id='".$_GET['StockID']."' ");
while($result=mysql_fetch_array($query)){
$i++;
if($result["StockID"]==$_GET["StockID"]){
$sel="selected";
} else {
$sel="";
}
?>
<option value="?StockID=<?=$result["StockID"];?>" <?=$sel; ?>><?=$result["StockCode"];?></option>
<?
}
?>
</select>
|
 |
 |
 |
 |
Date :
2012-03-05 22:07:56 |
By :
บังเอิญผ่านมาเห็น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รู้แล้วครับตรง group คุณเป็น string ครับ จะต้องใส่ตัวนี้ด้วยครับ
Code (JavaScript)
strGroup = "<?=$objResult["mn_id"];?>";
|
 |
 |
 |
 |
Date :
2012-03-06 10:12:46 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับผม ขอขอบคุณคุณพี่ วิน และก็คุณ Guest ที่ให้คำแนะนำ ขอบคุณครับ
|
ประวัติการแก้ไข 2012-03-06 20:43:41
 |
 |
 |
 |
Date :
2012-03-06 19:35:15 |
By :
sibsan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|