<?
Require dirname (_ file _). '/include/common. Inc. php ';
Global $ dB;
$ Area = $ db-> select ("select * From cms_area where parentid = 0 ");
?>
<Form ID = "myform" name = "myform" Action = "" method = "Post">
<Select name = "areaid" id = "areaid" onchange = "getarea2 (document. myform. areaid. Options [document. myform. areaid. selectedindex]. Value);">
<Option value = "-1">-select-</option>
<? Foreach ($ area as $ R) {?>
<Option value = "<? = $ R [areaid]?> "> <? = $ R ['name']?> </Option>
<? }?>
</SELECT>
<Select name = "areaid2" id = "areaid2">
<Option value = "-1">-business area-</option>
</SELECT>
</Form>
<SCRIPT>
Function getarea2 (PID)
{
VaR area = new array ();
VaR num = 0;
VaR DATA = new array ();
<? PHP
$ Area = getarea ();
$ Rownum = count ($ area );
For ($ I = 0; $ I <$ rownum; $ I ++ ){
Echo "data [". $ I. "] = new array ('". $ area [$ I] ["name"]. "',". $ area [$ I] ["areaid"]. ",". $ area [$ I] ["parentid"]. ") \ n"; // create a two-dimensional array with array _ option elements. The first column is the text of the city, and the second column is the city id, the third column is the parent ID of the city.
}
?>
Document. getelementbyid ('areaid2'). Length = 0;
For (I = 0; I <data. length; I ++)
{
If (data [I] [2] = PID)
{
Document. getelementbyid ('areaid2 '). options [document. getelementbyid ('areaid2 '). length] = New Option (data [I] [0], data [I] [1]);
}
}
}
</SCRIPT>
<?
Function getarea ()
{
Global $ dB;
$ Area = $ db-> select ("select * From cms_area where parentid in (select areaid from cms_area where parentid = 0 )");
Return $ area;
}
?>