|
 |
|
ทำ select box จากตาราง แต่ไม่บันทึกค่าให้ ช่วยให้ทีครับ |
|
 |
|
|
 |
 |
|

อันนี้เป็นโค้ดครับ
Code (PHP)
<script language="JavaScript" type="text/javascript">
function check_number() {
e_k=event.keyCode
//if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) {
if (e_k != 13 && (e_k < 48) || (e_k > 57)) {
event.returnValue = false;
alert("ต้องเป็นตัวเลขเท่านั้น... \nกรุณาตรวจสอบข้อมูลของท่านอีกครั้ง...");
}
}
function ListType(SelectValue)
{
frmMain.type.length = 0
frmMain.kind.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.type.options[frmMain.type.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM type ORDER BY type_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["sec_id"];?>;
strValue = "<?=$objResult["type_id"];?>";
strItem = "<?=$objResult["type_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.type.options[frmMain.type.length]= myOption
}
<?
}
?>
}
function ListKind(SelectValue)
{
frmMain.kind.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
frmMain.kind.options[frmMain.kind.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM kind ORDER BY kind_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["type_id"];?>;
strValue = "<?=$objResult["kind_id"];?>";
strItem = "<?=$objResult["kind_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.kind.options[frmMain.kind.length]= myOption
}
<?
}
?>
}
</script>
<form name="frmMain" action="add2.php" method="post">
<td width="225">
<tr>
<td colspan="2" align="center">
</tr>
<tr> <tr>
<td colspan="2" align="center">
</tr>
<tr>
<td colspan="2" align="left">ประเภท
<select id="sec" name="sec" onchange = "ListType(this.value)">
</option>
<?
$strSQL = "SELECT * FROM geography ORDER BY sec_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["sec_id"];?>">
<?=$objResult["sec_name"];?>
</option>
<?
}
?>
</select>
ลักษณะ
<select id="type" name="type" onchange = "ListKind(this.value)">
</select>
ชนิด
<select id="kind" name="kind">
</select>
</tr>
<?
mysql_close($objConnect);
?>
</form>
<td width="225"></td>
<td width="343">
<tr>
<td colspan="2"> </td>
<td width="4">
<tr> <form name="frmMain1" action="add2.php" method="post">
<td colspan="3" align="left"> จำนวน
<input name="rai" type="text" onkeypress="checknumber()" value=0 size="4" maxlength="4" />
ไร่
<input name="ngan" type="text" onkeypress="checknumber()" value=0 size="4" maxlength="4" />
งาน
<input name="tarang" type="text" onkeypress="checknumber()" value=0 size="4" maxlength="4" />
ต.ร.ว </td>
<tr>
<td colspan="2"> </td>
<td>
<tr>
<td colspan="2">พิกัด X <input name="rangx" type="text" id="rangx" size="10" />
พิกัด Y
<input name="rangy" type="text" id="rangy" size="10" /></td>
<td>
<tr>
<td colspan="3" align="center"> </td>
<tr>
<td colspan="3" align="left">บันทึกเพิ่มเติม<input name="memo" type="text" id="memo" size="50" /></td>
<tr>
<td colspan="3" align="center"> </td>
<tr>
<td colspan="3" align="center"><input type="hidden" name="cid" value="<?=$cid?>" />
<input type = "submit" value ="บันทึก" />
<input type ="reset" value ="ยกเลิก"/> </td>
<tr>
<td>
<tr>
<td colspan="7" bgcolor="#FFFFFF"></td>
</form>
<td width="225"></td>
</tr>
</table>
Tag : PHP

|
ประวัติการแก้ไข 2011-07-23 00:53:29 2011-07-23 01:03:47
|
 |
 |
 |
 |
Date :
2011-07-23 00:51:36 |
By :
salieaf |
View :
746 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รูปอัพไม่ขึ้นครับ
|
 |
 |
 |
 |
Date :
2011-07-23 00:55:54 |
By :
salieaf |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันจะต้องดูตอนที่ทำการ Save ครับ ว่ามีค่าตัวแปรหรือไม่ 
|
 |
 |
 |
 |
Date :
2011-07-23 08:43:48 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|