Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > การทำ list menu 2 ชั้น เลือกภาคแล้วแสดงจังหวัดในภาคนั้ๆแต่เลือกภาคแล้วจังหวัดไม่ขึ้น



 

การทำ list menu 2 ชั้น เลือกภาคแล้วแสดงจังหวัดในภาคนั้ๆแต่เลือกภาคแล้วจังหวัดไม่ขึ้น

 



Topic : 075947



โพสกระทู้ ( 121 )
บทความ ( 0 )



สถานะออฟไลน์




Code (PHP)
<? //require_once("Db_Connect.php"); 
   require_once("include/config.php");
   require_once("include/opendb.php"); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"> 
<title>Untitled Document</title>
<script language = "JavaScript">
		//**** List pv (province) ***//
		function ListPv(SelectValue)
		{
			frmMain.Pv.length = 0
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.Pv.options[frmMain.Pv.length]= myOption
			<?
			$intRows = 0;
			$strSQL = "SELECT * FROM province order by provinceid ";
			$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["geoid"];?>;
				strValue = "<?=$objResult["provinceid"];?>";
				strItem = "<?=$objResult["provincename"];?>";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
			<?
			}
			?>
		
		}		
		//**** List Pv (End) ***//
</script>
</head>
<body>
<form name="frmMain" action="" method="post">

  Geo
    <select id="geo" name="geo" onChange = "ListPv(this.value)">
	<option selected value=""></option>
	<?
	$strSQL = "SELECT * FROM geo ORDER BY geoid ASC ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	<option value="<?=$objResult["geoid"];?>"><?=$objResult["geoname"];?></option>
	<?
	}
	?>
	</select>
Province
  <select id="Pv" name="Pv" style="width:100px"></select>
  </br>
  
</form>
</body>
</html>

จากโค้ด
การทำ list menu 2 ชั้น เลือกภาคแล้วแสดงจังหวัดในภาคนั้ๆแต่เลือกภาคแล้วจังหวัดไม่ขึ้น
ผิดตรงไหนครับ



Tag : PHP, MySQL, JavaScript







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-22 11:47:00 By : kung1451 View : 3186 Reply : 6
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

View หน้า Source ของ IE มาให้หน่อยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 11:51:20 By : webmaster
 


 

No. 2



โพสกระทู้ ( 121 )
บทความ ( 0 )



สถานะออฟไลน์


Code (PHP)
 
 
 
 
 
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"> 
<title>Untitled Document</title>
<script language = "JavaScript"> 
		//**** List pv (province) ***//
		function ListPv(SelectValue)
		{
			frmMain.Pv.length = 0
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.Pv.options[frmMain.Pv.length]= myOption
						
				x = 1;
				mySubList = new Array();
				strGroup = 2;
				strValue = "10";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 2;
				mySubList = new Array();
				strGroup = 2;
				strValue = "11";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 3;
				mySubList = new Array();
				strGroup = 2;
				strValue = "12";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 4;
				mySubList = new Array();
				strGroup = 2;
				strValue = "13";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 5;
				mySubList = new Array();
				strGroup = 2;
				strValue = "14";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 6;
				mySubList = new Array();
				strGroup = 2;
				strValue = "15";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 7;
				mySubList = new Array();
				strGroup = 2;
				strValue = "16";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 8;
				mySubList = new Array();
				strGroup = 2;
				strValue = "17";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
				x = 9;
				mySubList = new Array();
				strGroup = 2;
				strValue = "18";
				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.Pv.options[frmMain.Pv.length]= myOption					
				}
						
	
					
		}		
		//**** List Pv (End) ***//
</script>
</head>
<body>
<form name="frmMain" action="" method="post">
 
  Geo
    <select id="geo" name="geo" onChange = "ListPv(this.value)">
	<option selected value=""></option>
		<option value="1">เหนือ</option>
		<option value="2">กลาง</option>
		<option value="3">ตะวันออกเฉียงเหนือ</option>
		<option value="4">ตะวันออก</option>
		<option value="5">ตะวันตก</option>
		<option value="6">ใต้</option>
		</select>
Province
  <select id="Pv" name="Pv" style="width:100px"></select>
  </br>
  
</form>
</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 13:26:59 By : kung1451
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

สังเกตุว่าพวก

Code (PHP)
				strItem = "นนทบุรี
";


ทำไมมันถึงตกครับ ลอง trim ดูครับ


Code (PHP)
				strGroup = <?=$objResult["geoid"];?>;
				strValue = "<?=trim($objResult["provinceid"]);?>";
				strItem = "<?=trim($objResult["provincename"]);?>";

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 13:45:07 By : webmaster
 


 

No. 4



โพสกระทู้ ( 121 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วครับ
ทำไมใส่ trim ด้วยครับอธิบายหน่อย
ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 13:46:59 By : kung1451
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตัด space พวกช่องว่างออกครับ มันอาจจะมี \n\t ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 14:02:05 By : webmaster
 


 

No. 6



โพสกระทู้ ( 121 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-22 16:06:40 By : kung1451
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : การทำ list menu 2 ชั้น เลือกภาคแล้วแสดงจังหวัดในภาคนั้ๆแต่เลือกภาคแล้วจังหวัดไม่ขึ้น
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่