简体   繁体   中英

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() .

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 .

Your need to pass all those values to url via GET or POST request and you can get all the values through uri segments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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