|
 |
|
สอบถามปัญหา Dependent ListMenu ตอนเก็บลง MySQL มันเกบลงเป็นตัวเลขค่ะ |
|
 |
|
|
 |
 |
|
Code (PHP)
<script language = "JavaScript">
//**** List Province (Start) ***//
function Listtype_agencies(SelectValue)
{
form1.ddltype_agencies.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.ddltype_agencies.options[form1.ddltype_agencies.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM civic_type_agencies 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["agencies_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])
form1.ddltype_agencies.options[form1.ddltype_agencies.length]= myOption
}
<?
}
?>
}
</script>
</head>
<body>
<form name="form1" method="post" action="up_pic2.php" enctype="multipart/form-data">
Name : <input type="text" name="txtName"><br>
Picture : <input type="file" name="filUpload"><br>
<tr>
<td> </td>
<td><div align="left"><strong>Year:</strong>
<select id="ddlyear" name="ddlyear" style="width:200px">
<option selected value=""></option>
<?
$strSQL = "SELECT * FROM civic_year ORDER BY year_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["year"];?>">
<?=$objResult["year"];?>
</option>
<?
}
?>
</select><br />
<strong>agencies:</strong>
<select id="ddlagencies" name="ddlagencies" style="width:200px" onChange = "Listtype_agencies(this.value)">
<option selected value="<?=$objResult["agencies"];?>"></option>
<?
$strSQL = "SELECT * FROM civic_agencies ORDER BY agencies_id ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["agencies"];?>">
<?=$objResult["agencies"];?>
</option>
<?
}
?>
</select><br />
Type Agencies
<select id="ddltype_agencies" name="ddltype_agencies" style="width:200px">
</select>
<input name="btnSubmit" type="submit" value="Submit" />
</div>
</form>
|
 |
 |
 |
 |
Date :
2012-07-11 13:30:14 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเปลี่ยน
strValue = "<?=$objResult["type_id"];?>"; เป็น strValue = "<?=$objResult["type_name"];?>"; ดูครับ
|
 |
 |
 |
 |
Date :
2012-07-11 13:44:29 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าได้ ตัวเลขมา หน้า แสดงผล เรา้จะไปดึงข้อความจากอีกตารางมาโชว์เราต้องเขียนไงหรอค่ะ

คือได้เลข1 มา
แต่จะแสดงผล ว่า ภาครัฐ จะต้องทำไรค่ะ
|
 |
 |
 |
 |
Date :
2012-07-11 15:36:44 |
By :
itzalone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|