2
所以,我在Joomla的RSForm Pro中有這個註冊表單,在那裏我有兩個下拉列表。一個從mySQL獲取美國國家和一個從該州獲取城市/縣的人。問題是,我不知道如何檢查用戶在第一個下拉列表中選擇的狀態。我找到了一種手動方式(爲每個狀態創建一個列表),但這不夠好。它應該自動完成。Joomla RSForm Pro Dynamic Dropdown
請幫忙!
這是我用來填充第一個下拉列表(包含狀態)的一段代碼。這放在RSForm Pro的「項目」字段中:
//<code>
$interestedstates = array();
$db = JFactory::getDbo();
$interestedstates[] = "|Please Select[c]";
$db->setQuery("SELECT id, state_name FROM #__osrs_states");
$results = $db->loadObjectList();
foreach ($results as $result) {
$value = $result->id;
$label = $result->state_name;
$interestedstates[] = $value.'|'.$label;
}
$interestedstates = implode("\n", $interestedstates);
return $interestedstates;
//</code>
非常感謝!