简体   繁体   English

如何在CodeIgniter中的控制器中获取选择框的选项值

[英]How to get the option value of the select box in the controller in CodeIgniter

I have a controller with the index function() and I would like to get the selected value of the option value of the view in the controller index() . 我有一个带有索引function()的控制器,我想在控制器index()中获取视图的选项值的选定值。

public function index() {
    $this->accesscontrol->can_or_redirect('view', 'translation');
    $this->output->view('translation/language');
}

My view is as follows: 我的看法如下:

<select name="lang_choice1" id="lang_choice1">
    <?php
    $path = './application/language/';
    $dir = new DirectoryIterator($path);
    foreach ($dir as $fileinfo) {
        if ($fileinfo->isDir() && !$fileinfo->isDot()) {
            echo "<option value='" . $fileinfo->getFilename() . "'>".$fileinfo->getFilename()."</option>";
        }
    }
    ?>
</select>

创建一个带有方法post的表单标签,并为控制器设置操作URL,还创建一个类型为Submit的按钮,以便在提交表单时可以在控制器中获取选定的值

If you need return any value back to CONTROLLER from VIEW . 如果您需要将任何值从VIEW返回给CONTROLLER

Your need to pass all those values to url via GET or POST request and you can get all the values through uri segments. 您需要通过GETPOST请求将所有这些值传递给url ,然后可以通过uri段获取所有值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM