如何在codeigniter中将文本输入值更改为下拉列表

如何在codeigniter中将文本输入值更改为下拉列表,codeigniter,Codeigniter,我有这样一个控制器:unitselector.php <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Unitselector extends CI_Controller { function __construct() { parent::__construct(); //$this->load->model(array('Transak

我有这样一个控制器:
unitselector.php

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Unitselector extends CI_Controller {

function __construct() {
    parent::__construct();
    //$this->load->model(array('Transaksi_model', 'Pelanggan_model'));
    //chek_session();
}

function index() {
    if (!$this->ion_auth->logged_in()) {
        // redirect them to the login page
        redirect('auth/login', 'refresh');
    } else{
        $this->db->order_by("unit_order");
        $data['record']=  $this->db->get('tb_unit_list')->result();
        $unitid = $this->input->get('hiddenInput');
        $data['record1']=  $this->db->query("SELECT * FROM tb_unit_location where id_unit='$unitid' ")->result();
        $data['record2']=  $this->db->query("SELECT * FROM tb_period WHERE Status = 0")->result();
        $this->load->view('unitselector/unitselector',$data);
    }
}

}
我已经将
%unitid
定义为值。但它没有效果。请帮助。

您可以:

$('#dropdown1').change(function(){
    window.location.href = 'unitselector/index?hiddenInput1=' + $(this).val();
});

或者使用ajax加载。

Hi Maxim,感谢您的友好解决方案。如何在代码中应用?在控制器或视图中?$('#dropdown1').change(function(){window.location.href='unitselector/index?hiddenInput1='+$(this.val();});//在viewHi Maxim中,非常感谢它的工作:),但当单击时,下拉列表1中的文本会消失。$(document).ready(函数(){$('#dropdown1').change(函数(){window.location.href=“unitselector/index?hiddenInput=“+$(this).val();//history.pushState(null,'Unit Selector',unitselector/index?hiddenInput=”+$(this.val());//$(“#dropdown2”).val(“”);//window.history.back();//window.history.forward();//window.history.go(2);});});我试图发出此命令,但此后该值不会改变javascript函数是什么?
$data['record1']=  $this->db->query("SELECT * FROM tb_unit_location where id_unit='$unitid' ")->result();
$('#dropdown1').change(function(){
    window.location.href = 'unitselector/index?hiddenInput1=' + $(this).val();
});