Codeigniter 中的 Form_Dropdown()
我需要有关如何在 Codeginiter 项目中使用 form_dropdown 的帮助。
查看文件:my_test.php 代码如下,
<?php
// basic filter form
$attributes = array('class' => 'formstyle', 'id' => 'myfilterform');
echo form_open('mytest/send', $attributes);
$options = array(
'all' => 'Pls Select Filter',
'male' => 'Male List',
'female' => 'Female List',
);
echo form_dropdown('myfilter', $options, 'male');
echo form_submit('myfiltersubmit', ' GO ');
$string = "</div></div>";
echo form_close($string);
?>
控制器文件 mytest.php 代码如下,
function index()
{
$data['title'] = "Hello";
$this->load->view('my_test', $data);
}
function send()
{
$mypostdata = $_POST['options']; // I can't get the post data here.
echo $mypostdata;
}
我确实阅读了 CI UserGuide 上的 form_dropdown 部分。不幸的是我没有找到如何处理 send()
中的发布数据。谢谢。
I need help on how to use the form_dropdown in Codeginiter project.
View file: my_test.php code as this,
<?php
// basic filter form
$attributes = array('class' => 'formstyle', 'id' => 'myfilterform');
echo form_open('mytest/send', $attributes);
$options = array(
'all' => 'Pls Select Filter',
'male' => 'Male List',
'female' => 'Female List',
);
echo form_dropdown('myfilter', $options, 'male');
echo form_submit('myfiltersubmit', ' GO ');
$string = "</div></div>";
echo form_close($string);
?>
Controllers file mytest.php code as this,
function index()
{
$data['title'] = "Hello";
$this->load->view('my_test', $data);
}
function send()
{
$mypostdata = $_POST['options']; // I can't get the post data here.
echo $mypostdata;
}
I did read the form_dropdown portion on CI UserGuide. unfortunately I didn't find how to handle post data in send()
. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取下拉列表的选定值,您需要获取 $_POST['myfilter'] (假设“myfilter”是下拉列表的名称)。
一般来说,要调试 POST 数据,您可能需要执行“var_dump($_POST)” " 这将向您显示所有 POST 数据并帮助您弄清楚如何检索每个值。
To get the dropdown's selected value, you need to get $_POST['myfilter'] (assuming "myfilter" is the name of your dropdown)
In general, to debug POST data, you might want to do a "var_dump($_POST)" That will show you all the POST data and help you figure out how to retrieve each value.