|
|
|
สอบถามปัญหา-OnChange แล้วไม่เปลี่ยนค่าครับ เลือกจาก popup |
|
|
|
|
|
|
|
ผมลองเอา ฟอร์มเลือกภาคแล้วจังหวัดเปลี่ยนตาม เปลี่ยนจาก 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"> </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"> </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> </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> </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"> </td>
<td> </td>
<td colspan="2"><input type="image" src="images/layout/submit.png" name="Submit"></td>
<td> </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
|
|
|
|
|
|
Date :
2013-07-09 11:26:20 |
By :
xmysteryz |
View :
953 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input น่าจะใช้เป็น Onkeyอะไรสักอย่างนี่หละ
|
|
|
|
|
Date :
2013-07-09 11:29:06 |
By :
RootElement@KMUTNB |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หรือต้อง where รับค้าจาก textbox แรกมาเอ่ยๆๆ ลองกำหนดค่ามาได้เฉย
Code (PHP)
$strSQL = "SELECT * FROM province where GEO_ID = '2'";
|
|
|
|
|
Date :
2013-07-09 11:43:39 |
By :
xmysteryz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-07-09 14:30:37 |
By :
xmysteryz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|