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 > สอบถามปัญหา-OnChange แล้วไม่เปลี่ยนค่าครับ เลือกจาก popup



 

สอบถามปัญหา-OnChange แล้วไม่เปลี่ยนค่าครับ เลือกจาก popup

 



Topic : 097567



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



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




ผมลองเอา ฟอร์มเลือกภาคแล้วจังหวัดเปลี่ยนตาม เปลี่ยนจาก Listmenu มาเป็น Popup แทน
แต่ค่าที่ออกมากลับไม่เปลี่ยนเหมือนตอนเป็น ListMenu ครับ


index (PHP)
<?php
	$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
	$objDB = mysql_select_db("thailand");
	@mysql_query("SET NAMES UTF8");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/Calendar.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/Calendar.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#frmOrg").hide();
	$("#frmPeo").hide();

  $("#btnOrg").click(function(){
	$("#frmOrg").show();
	$("#frmPeo").hide();
  });

  $("#btnPeo").click(function(){
	$("#frmOrg").hide();
	$("#frmPeo").show();
  });

});
</script>
<script language = "JavaScript">

		//**** List Geography (Start) ***//
		function ListGeography(SelectValue)
		{
			frmMain.txtGeo_1.length = 0
			frmMain.txtProvince_1.length = 0
			
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.txtGeo_1.options[frmMain.txtGeo_1.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL = "SELECT * FROM geography ORDER BY NA_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["NA_ID"];?>;
				strValue = "<?=$objResult["GEO_ID"];?>";
				strItem = "<?=$objResult["GEO_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.txtGeo_1.options[frmMain.txtGeo_1.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List Geography (End) ***//
		

		//**** List Province (Start) ***//
		function ListProvince(SelectValue)
		{
			frmMain.txtProvince_1.length = 0
			frmMain.txtAmphur_1.length = 0
			
			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.txtProvince_1.options[frmMain.txtProvince_1.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL = "SELECT * FROM province ORDER BY PROVINCE_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["GEO_ID"];?>;
				strValue = "<?=$objResult["PROVINCE_ID"];?>";
				strItem = "<?=$objResult["PROVINCE_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.txtProvince_1.options[frmMain.txtProvince_1.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List Province (End) ***//

		
		//**** List Amphur (Start) ***//
		function ListAmphur(SelectValue)
		{
			frmMain.txtAmphur_1.length = 0

			//*** Insert null Default Value ***//
			var myOption = new Option('','')  
			frmMain.txtAmphur_1.options[frmMain.txtAmphur_1.length]= myOption
			
			<?
			$intRows = 0;
			$strSQL = "SELECT * FROM amphur ORDER BY AMPHUR_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["PROVINCE_ID"];?>;
				strValue = "<?=$objResult["AMPHUR_ID"];?>";
				strItem = "<?=$objResult["AMPHUR_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.txtAmphur_1.options[frmMain.txtAmphur_1.length]= myOption					
				}
			<?
			}
			?>																	
		}
		//**** List Amphur (End) ***//

</script>
<script language="javascript">

	function OpenPopupGeo(intLine)
	{
		window.open('getGeo.php?Line='+intLine,'myPopup1','width=900,height=600,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');
	}
	function OpenPopupPro(intLine)
	{
		window.open('getPro.php?Line='+intLine,'myPopup2','width=930,height=650,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');

	}
		function OpenPopupAmp(intLine)
	{
		window.open('getAmp.php?Line='+intLine,'myPopup3','width=930,height=650,toolbar=0, menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');

	}
	
</script>

<style type="text/css">
<!--
body {
	background-image: url(images/layout/background.jpg);
}
.style1 {
	color: #FFFFFF;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style2 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>
<body class="oneColFixCtrHdr">
<div align="center"><img src="images/layout/header.png" />
<div id="container">
  <div id="header">
    <h1 class="style1">JobService</h1>
    <!-- end #header --></div>
  <div id="mainContent" style="height:590px;">
  <fieldset style="height:500px;">
  <legend><h1>แบบฟอร์มรับแจ้งงาน</h1></legend>
    <table width="850" height="80" frame="void" rules="rows">
<tr>
        	<td width="104" height="21" background="images/layout/HeadClass.png">&nbsp;</td>
       	<td width="310" background="images/layout/HeadClass.png"></td>
       	  <td width="365" background="images/layout/HeadClass.png"></td>
       	  <td width="51" background="images/layout/HeadClass.png"></td>
      </tr>
        <tr>
        	<td height="24"><div align="center"><strong>วันที่รับเรื่อง</strong></div></td><td><input name="date" size="20" />
        	  <a href="javascript:displayDatePicker('date')"> <img border="0" src="images/Calendar/calendar.gif" width="13" height="12"></a></td><td></td><td></td>
        </tr>
        <tr><td colspan="4"></td>
        </tr>

    </table>
    <form name="frmMain" method="post" action="">
<?
	mysql_query("SET NAMES UTF8");
	$strSQL = "SELECT * FROM nation ORDER BY NA_ID ASC ";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$objResult = mysql_fetch_array($objQuery);
	
	?>
<table align="center">
<tr>
<td colspan="4">
	
	<input type="radio" name="rdoNA" id="btnOrg" value="<?=$objResult["NA_NAME"]=1?>" onChange = "ListGeography(this.value)">ประเทศไทย

    <input type="radio" name="rdoNA" id="btnPeo" value="<?=$objResult["NA_NAME"]=2?>" onChange = "ListGeography(this.value)">เพิ่มประเทศใหม่

</td>
</tr>
</table>
<div id="frmOrg">
<table align="center" width="500">
      <tr>
        <td width="109" height="25">Geography</td>
        <td width="6">&nbsp;</td>
        <td colspan="2"><input type="text" id="txtGeo_1" name="txtGeo_1" style="width:200px" onChange = "ListProvince(this.value)"></td>
        <td width="118"><input type="button" name="btnPopup1" id="btnPopup1" value="เลือก" onclick="OpenPopupGeo(1)"></td>
      </tr>
      <tr>
        <td height="25">Province</td>
        <td>&nbsp;</td>
        <td colspan="2"><input type="text" id="txtProvince_1" name="txtProvince_1" style="width:200px" onChange = "ListAmphur(this.value)"></td>
        <td><input type="button" name="btnPopup2" id="btnPopup2" value="เลือก" onclick="OpenPopupPro(1)"></td>
      </tr>
      <tr>
        <td height="25">Amphur </td>
        <td>&nbsp;</td>
        <td colspan="2"><input type="text" id="txtAmphur_1" name="txtAmphur_1" style="width:200px">
        </select>        </td>
        <td><input type="button" name="btnPopup3" id="btnPopup3" value="เลือก" onclick="OpenPopupAmp(1)"></td>
      </tr>
            <tr>
        <td height="25">&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan="2"><input type="image" src="images/layout/submit.png" name="Submit"></td>
        <td>&nbsp;</td>
      </tr>
    </table>
</div>
</form>


  
  </fieldset>
  <!-- end #mainContent -->
  </div>

  <div id="footer">
    <p class="style2">Copyright © 2013 by xMysteryZ. Thailand.</p>
    <!-- end #footer --></div>
<!-- end #container --></div>
<div align="center"><img src="images/layout/footer.png" /></div>
</div>
</body>
</html>





Popup เลือก ภาค (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script language="javascript">
	function selData(intLine,GEO_ID)
	{
		var sGEO_ID = self.opener.document.getElementById("txtGeo_"+intLine);
		sGEO_ID.value = GEO_ID;

		//var sGEO_NAME = self.opener.document.getElementById("txtGEO_NAME"+intLine);
		//sGEO_NAME.value = GEO_NAME;

		window.close();
	}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("thailand");
@mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM geography";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>

<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">GEO_ID </div></th>
    <th width="98"> <div align="center">GEO_NAME </div></th>
  </tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
  <tr>
    <td><div align="center"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["GEO_NAME"];?>');">
	<?=$objResult["GEO_NAME"];?>
	</a></div></td>
    <td></td>
  </tr>
<?
}
?>
</table>

<?
mysql_close($objConnect);
?>
</body>
</html>




Popup เลือกจังหวัด (PHP)
<html>
<head>
<title>ThaiCreate.Com</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script language="javascript">
	function selData(intLine,PROVINCE_ID)
	{
		var sPROVINCE_ID = self.opener.document.getElementById("txtProvince_"+intLine);
		sPROVINCE_ID.value = PROVINCE_ID;

		//var sPROVINCE_NAME = self.opener.document.getElementById("txtPROVINCE_NAME"+intLine);
		//sPROVINCE_NAME.value = PROVINCE_NAME;

		window.close();
	}
</script>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("thailand");
@mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM province";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>

<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">PROVINCE_ID </div></th>
    <th width="98"> <div align="center">PROVINCE_NAME </div></th>
  </tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
  <tr>
    <td><div align="center"><a href="#" OnClick="selData('<?=$_GET["Line"];?>' ,'<?=$objResult["PROVINCE_NAME"];?>');">
	<?=$objResult["PROVINCE_NAME"];?>
	</a></div></td>
    <td></td>
  </tr>
<?
}
?>
</table>

<?
mysql_close($objConnect);
?>
</body>
</html>



รบกวนด้วยนะครับ เด๊วไปงงมต่อ ^^



Tag : PHP, MySQL, Oracle, JavaScript, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-07-09 11:26:20 By : xmysteryz View : 915 Reply : 3
 

 

No. 1

Guest


input น่าจะใช้เป็น Onkeyอะไรสักอย่างนี่หละ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-09 11:29:06 By : RootElement@KMUTNB
 


 

No. 2



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



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


หรือต้อง where รับค้าจาก textbox แรกมาเอ่ยๆๆ ลองกำหนดค่ามาได้เฉย
Code (PHP)
$strSQL = "SELECT * FROM province where GEO_ID = '2'";

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-09 11:43:39 By : xmysteryz
 

 

No. 3



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



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



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-09 14:30:37 By : xmysteryz
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามปัญหา-OnChange แล้วไม่เปลี่ยนค่าครับ เลือกจาก popup
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 04
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 อัตราราคา คลิกที่นี่