1

我想使用 codeigniter 填充选择下拉列表form_dropdown,因为我在下面的代码中编写了该下拉列表view

                 $experience = array(
                    "" => "- Min Exp -",
                    "0" => "Freshers & <1 Yr",
                    "1" => "1 Yr",
                    "2" => "2 Yrs",
                    "3" => "3 Yrs",
                    "4" => "4 Yrs",
                    "5" => "5 Yrs",
                    "6" => "6 Yrs"
                );

$js = 'id="minexp" style="width: 95%;padding-top: 7px" required';
echo form_dropdown('minexp', $experience, $this->input->post('minexp'), $js);

重新填充工作完美,但默认情况下,它选择Freshers & <1 Yr并且我希望- Min Exp -在用户第一次查看页面时选择它。

任何帮助或建议都会有很大帮助..我用谷歌搜索并没有找到任何解决方案..

4

1 回答 1

1

尝试首先检查帖子数据是否存在。

echo form_dropdown('minexp', $experience, (($this->input->post('minexp')) ? $this->input->post('minexp') : ''), $js);
于 2014-02-24T22:13:48.880 回答