搬家業界第一家推薦之
優良搬家公司
客源網租屋就找
明日黃金屋

首頁  •  tw 論壇 • 程式設計討論     • 

[教學]php動態下拉式選單 2階層

房東:小明
發表時間:2010-03-02
[檢舉]




Dynamic Dropdown for Country and City List




/*
- Function to return the Country list as an array
- The array can be generated from a database resultset
*/
function getCountryList()
{
// Country List array
$countryList = array (
\'1\' => \'Bangladesh\',
\'2\' => \'USA\',
\'3\' => \'UK\'
);

return $countryList;
}

/*
- Function to return the City list as an array
- Country ID is used to generate the city list
*/
function getCityList($countryId)
{
// City list array
// First key of the array is the Country ID, which holds an array of City list
$cityList = array (
\'1\' => array (\'Dhaka\', \'Chittagong\', \'What else\'),
\'3\' => array (\'London\', \'Cannot Remember\'),
\'2\' => array (\'Washington\', \'N.Y.\', \'etc\')
);

return $cityList[$countryId];
}
?>



// Retrieving the country list
$countryList = getCountryList();

// Setting the variable if the country is selected for its city list
@$countryId = $_GET[\'countryId\'];

// Retrieving the city list if a country is selected
$cityList = ($countryId) ? getCityList($countryId) : null;

if (!empty($countryList))
{
// Generating the country drop down menu
echo \"\";
}

if (!empty($cityList))
{
// Generating the city drop down menu if a country is selected
echo \"\";
}

?>






http://blog.roodo.com/taikobo0/archives/8671037.html



  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!

  • 1 樓住戶:阿偉
    發表時間:2010-03-24
    [檢舉]

    http://tw.knowledge.yahoo.com/question/question?qid=1510020409088



     共 1 人回應  選擇頁數 【第1 頁】 

    姓名:
    佈告內容: