|
|
|
สอบถามปัญหา-อยากทราบแนวทางวิธีการสร้าง radio แล้วฟอร์มแสดงต่างกัน |
|
|
|
|
|
|
|
ได้แล้วครับ ขอบคุณทุกคนที่เข้ามาอ่าน หรืออาจกำลังลองช่วยผมอยู่และทุกบทความทั้งหมดจากบอร์ดนะครับ
เผื่อใครอยากได้แบบผม ^^
หรือจะช่วยเพิ่มเติมจากโค้ดผมให้สมบูรณ์ก็ยินดีครับ
Code (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.ddlGeo.length = 0
frmMain.ddlProvince.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlGeo.options[frmMain.ddlGeo.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.ddlGeo.options[frmMain.ddlGeo.length]= myOption
}
<?
}
?>
}
//**** List Geography (End) ***//
//**** 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;
$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.ddlProvince.options[frmMain.ddlProvince.length]= myOption
}
<?
}
?>
}
//**** List Province (End) ***//
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
frmMain.ddlAmphur.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.ddlAmphur.options[frmMain.ddlAmphur.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.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
}
<?
}
?>
}
//**** List Amphur (End) ***//
</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="130" height="25">Geography</td>
<td width="10"> </td>
<td colspan="2"><select id="ddlGeo" name="ddlGeo" style="width:200px" onChange = "ListProvince(this.value)"></select></td>
<td width="14"> </td>
</tr>
<tr>
<td height="25">Province</td>
<td> </td>
<td colspan="2"><select id="ddlProvince" name="ddlProvince" style="width:200px" onChange = "ListAmphur(this.value)"></select></td>
<td> </td>
</tr>
<tr>
<td height="25">Amphur </td>
<td> </td>
<td colspan="2"><select id="ddlAmphur" name="ddlAmphur" style="width:200px">
</select> </td>
<td> </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>
<div id="frmPeo">
<form name="frmSub" method="post" action="">
<table align="center" width="500">
<tr>
<td height="25" width="130">Geography</td>
<td width="10"> </td>
<td colspan="2"><input type="text" id="txtGeo" name="txtGeo" style="width:200px"></td>
<td> </td>
</tr>
<tr>
<td height="25">Province</td>
<td> </td>
<td colspan="2"><input type="text" id="txtProvince" name="txtProvince" style="width:200px"></td>
<td> </td>
</tr>
<tr>
<td height="25">Amphur </td>
<td> </td>
<td colspan="2"><input type="text" id="txtAmphur" name="txtAmphur" style="width:200px">
</select> </td>
<td> </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>
</form>
</div>
</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>
|
|
|
|
|
Date :
2013-07-06 17:16:17 |
By :
xmysteryz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|