|  |  | 
          
            | อยากให้เวลากด เมื่อเลือก select box ยี่ห้อ --> ปลดล็อก แบบรุ่น --> แล้วก็มีเฉพาะรุ่นของยี่ห้อนั้นอะครับ ช่วยทีนะครับผม
    
 
  
 
 ไม่ทราบว่า code นี้ใช้ได้มั้ยครับ พอดี หามาแล้วลองเอามาแก้ไขแต่ไม่ออกครับ
 ออกแค่ข้อมูลแรก ช่วยดูให้หน่อยครับ ผมใช้ดึงข้อมูลจาก tb เดียวอะครับ
 **tb car ฟิล brand_car , gene_car , year_car**
 
 
  
 Code
 Code (PHP)
 
 <?php require_once('Connections/ConnectSW.php'); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ThaiCreate.Com ListMenu</title>
<script language = "JavaScript">
		//**** List Province (Start) ***จังหวัด//
		function ListProvince(SelectValue)
		{
			frmMain.ddlProvince.length = 0
			frmMain.ddlAmphur.length = 0
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL1 = "SELECT * FROM car ORDER BY brand_car ASC ";
			$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
			$intRows = 0;
			while($objResult1 = mysql_fetch_array($objQuery1))
			{
			$intRows++;
			?>			
				x = <?=$intRows;?>;
				mySubList = new Array();
				
				strGroup = <?=$objResult1["brand_car"];?>;
				strValue = "<?=$objResult1["brand_car"];?>";
				mySubList[x,0] = strGroup;
				mySubList[x,1] = strValue;
				if (mySubList[x,0] == SelectValue){
					var myOption = new Option(mySubList[x,1])  
					frmMain.ddlProvince.options[frmMain.ddlProvince.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List Province (End) ***//
		
		//**** List Amphur (Start) ***อำเภอ//
		function ListAmphur(SelectValue)
		{
			frmMain.ddlAmphur.length = 0
			frmMain.ddldistrict.length = 0
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL1 = "SELECT * FROM car ORDER BY brand_car ASC ";
			$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
			$intRows = 0;
			while($objResult1 = mysql_fetch_array($objQuery1))
			{
			$intRows++;
			?>
				x = <?=$intRows;?>;
				mySubList = new Array();
				
				strGroup = <?=$objResult1["brand_car"];?>;
				strValue = "<?=$objResult1["gene_car"];?>";
				mySubList[x,0] = strGroup;
				mySubList[x,1] = strItem;
							
				if (mySubList[x,0] == SelectValue){
					var myOption = new Option(mySubList[x,1])  
					frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List Amphur (End) ***อำเภอ//
		//**** List District (Start) *** ตำบล//
		function Listdistrict(SelectValue)
		{
			frmMain.ddldistrict.length = 0
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.ddldistrict.options[frmMain.ddldistrict.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL1 = "SELECT * FROM car ORDER BY gene_car ASC ";
			$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
			$intRows = 0;
			while($objResult1 = mysql_fetch_array($objQuery1))
			{
			$intRows++;
			?>
				x = <?=$intRows;?>;
				mySubList = new Array();
				
				strGroup = <?=$objResult1["gene_car"];?>;
				strValue = "<?=$objResult1["year_car"];?>";
				mySubList[x,0] = strGroup;
				mySubList[x,1] = strItem;
							
				if (mySubList[x,0] == SelectValue){
					var myOption = new Option(mySubList[x,1])  
					frmMain.ddldistrict.options[frmMain.ddldistrict.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List District (End) ***ตำบล//
</script>
</head>
<form name="frmMain" action="" method="post">
	
	Province
	<select id="ddlProvince" name="ddlProvince" style="width:120px" onChange="ListProvince(this.value)">
	 <option value="" hidden=""><-- เลือกรหัส --></option>
            <?php
			$strSQL1 = "SELECT DISTINCT brand_car FROM car ORDER BY brand_car ASC";
			$objQuery1 = mysql_query($strSQL1);
			while($objResult1 = mysql_fetch_array($objQuery1))
			{
			?>
            <option value="<?php echo $objResult1["brand_car"];?>"><?php echo $objResult1["brand_car"];?></option>
            <?php
			} 
			?> 
            </select>
	Amphur
	<select id="ddlAmphur" name="ddlAmphur" style="width:200px" onChange="ListAmphur(this.value)"></select>
	District
	<select id="ddldistrict" name="ddldistrict" style="width:200px" onChange="Listdistrict(this.value)"></select>
</form>
</body>
</html>
 
 
 Tag : PHP, MySQL
 
 
 |  
            | 
 ประวัติการแก้ไข
 2016-12-15 14:14:50
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2016-12-13 21:35:16 | By :
                          tomzone2 | View :
                          788 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |