01.
02.
function
ListAmphur(SelectValue)
03.
{
04.
frmMain.ddlAmphur.length = 0
05.
06.
07.
var
myOption =
new
Option(
''
,
''
)
08.
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
09.
10.
<?
11.
$intRows
= 0;
12.
$strSQL
=
"SELECT * FROM ms_sale_area"
;
13.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
14.
$intRows
= 0;
15.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
16.
{
17.
$intRows
++;
18.
?>
19.
x = <?=
$intRows
;?>;
20.
mySubList =
new
Array();
21.
22.
strGroup = <?=
$objResult
[
"province_code"
];?>;
23.
strValue =
"<?=$objResult["
area_code
"];?>"
;
24.
strItem =
"<?=$objResult["
area_name
"];?>"
;
25.
mySubList[x,0] = strItem;
26.
mySubList[x,1] = strGroup;
27.
mySubList[x,2] = strValue;
28.
29.
if
(mySubList[x,1] == SelectValue){
30.
var
myOption =
new
Option(mySubList[x,0], mySubList[x,2])
31.
frmMain.ddlAmphur.options[frmMain.ddlAmphur.length]= myOption
32.
}
33.
<?
34.
}
35.
?>
36.
}
37.
38.
39.
</script>
40.
41.
42.
</head>
43.
<form name=
"frmMain"
action=
""
method=
"post"
>
44.
45.
46.
Province
47.
<select id=
"ddlProvince"
name=
"ddlProvince"
style=
"width:120px"
onChange =
"ListAmphur(this.value)"
>
48.
<?
49.
$strSQL
=
"SELECT * FROM ms_province"
;
50.
$objQuery
= mysql_query(
$strSQL
)
or
die
(
"Error Query ["
.
$strSQL
.
"]"
);
51.
while
(
$objResult
= mysql_fetch_array(
$objQuery
))
52.
{
53.
?>
54.
<option value=
"<?=$objResult["
province_code
"];?>"
><?=
$objResult
[
"province_name"
];?></option>
55.
<?
56.
}
57.
?>
58.
59.
</select>
60.
61.
Amphur
62.
<select id=
"ddlAmphur"
name=
"ddlAmphur"
style=
"width:200px"
>
63.
64.
65.
</select>
66.
</form>
67.
</body>
68.
</html>
69.
<?
70.
mysql_close(
$objConnect
);