|
 |
|
เรื่องการดึงข้อมูลมาแก้ไขใน Dependent ListMenu [แนวคิดหน่อยครับ] |
|
 |
|
|
 |
 |
|
ขอบคุณครับพี่วิน
ดูแล้วยังงง เด่วเอาไปลองก่อนไม่ได้ยังไงจะกลับมาถามอีกนะครับ
^^
|
 |
 |
 |
 |
Date :
2010-09-30 16:41:03 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่งงหรอกครับ เอาไปใส่ตอน body onload ก็ได้ครับ คือหลังจากที่มีการโหลดค่าใส่ใน select หมดแล้ว ก็เอาตัวนี้ไปเชคเพื่อจะ selected ค่าเก่ากลับมาครับ
|
 |
 |
 |
 |
Date :
2010-09-30 16:45:18 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับพี่วิน...พี่วินน่าไปเปิดคอร์สสอนนะครับ
|
 |
 |
 |
 |
Date :
2010-09-30 16:46:40 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอดูตัวอย่างได้ไหมค่ะพี่
งงมากมากเลยคะ
จะแสดงเพื่อทำการแก้ไขจ.อ.ต.
จังหวัดโชว์ได้นะคะแต่โชว์ตำบลกับอำเภอไม่ได้อะคะ
ช่วยที่นะคะ(จะขอบคุณอย่างสูง)
form1นะคะ
Code (PHP)
<?
include("../inc/config3.php");
?>
<script language = "JavaScript">
//**** List Amphur (Start) ***//
function ListAmphur(SelectValue)
{
form1.ddlAmphur.length = 0
form1.ddlDistrict.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.ddlAmphur.options[form1.ddlAmphur.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM tbl_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])
form1.ddlAmphur.options[form1.ddlAmphur.length]= myOption
}
<?
}
?>
}
//**** List Amphur (End) ***//
//**** List District (Start) ***//
function ListDistrict(SelectValue)
{
form1.ddlDistrict.length = 0
//*** Insert null Default Value ***//
var myOption = new Option('','')
form1.ddlDistrict.options[form1.ddlDistrict.length]= myOption
<?
$intRows = 0;
$strSQL = "SELECT * FROM tbl_district ORDER BY district_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["amphur_id"];?>;
strValue = "<?=$objResult["district_id"];?>";
strItem = "<?=$objResult["district_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.ddlDistrict.options[form1.ddlDistrict.length]= myOption
}
<?
}
?>
}
//**** List District (End) ***//
</script>
<td height="23"><span style="color: #0000FF">จังหวัด :
<label>
<select name="ddlProvince" id="ddlProvince" onChange = "ListAmphur(this.value)">
<option value="-">ระบุจังหวัด</option>
<?
$strSQL = "SELECT * FROM tbl_province ORDER BY province_name ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["province_id"];?>" <? if($row[provinceID]==$objResult["province_id"]){echo"selected";}?>>
<?=$objResult["province_name"];?>
</option>
<?
}
?>
</select>
</label>
</span></td>
<td><span style="color: #0000FF">อำเภอ :
<label>
<select name="ddlAmphur" id="ddlAmphur" onChange = "ListDistrict(this.value)" >
<option selected value="-">ระบุอำเภอ</option>
<?
$strSQL = "SELECT * FROM tbl_amphur ORDER BY amphur_name ASC ";
$objQuery2 = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult2= mysql_fetch_array($objQuery2))
{
?>
<option value="<?=$objResult2["amphur_id"];?>" <? if($row[amphurID]==$objResult2["amphur_id"]){echo"selected";}?>>
<?=$objResult2["amphur_name"];?>
</option>
<?
}
?>
</select>
</label>
</span></td>
<td><span style="color: #0000FF">ตำบล :
<label>
<select name="ddlDistrict" id="ddlDistrict" >
<option value="-">ระบุตำบล</option>
</select>
</label>
</span></td>
<?
mysql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2011-07-12 14:54:44 |
By :
mai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ข้อดูตัวอย่าง ด้วยคนครับ
กำลังทำอยู่เหมือนกันครับ ขอความช่วยเหลือด้วยครับ !(q_๐)
|
 |
 |
 |
 |
Date :
2011-07-29 13:34:24 |
By :
pumin99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|