Welcome Guest, Not a member yet? Register   Sign In
Update a Select with onchange of other Select
#4

[eluser]abmcr[/eluser]
The php code in a view
Code:
$js = 'onChange="get_dati_gerachia()"';
echo form_dropdown('dati_gerarchia', $options, "TRUE",$js);echo "\n";
.....
    $id = 'id="master" ';
            $options = array(
                              'y'  => 'Master',
                              'n'  => 'Normale'
                            );
            echo "<span id='ajax_target'>".form_dropdown('master', $options,'',$id)."</span>";
and the js routine
Code:
function get_dati_gerachia(){
    var chosenItemText = $("select[name='dati_gerarchia']").val();
     a="data="+chosenItemText;
     $.ajax({
      type: "POST",
      url:  "&lt;?php echo site_url("the_url_of_your_ajax_controller")?&gt;",
      data: a,
      success: function(msg){
        $("#ajax_target").html(msg);
        }
    });
}
and your ajax controller
Code:
function the_url_of_your_ajax_controller(){
        $var=$this->input->post("data");
..... some operations and build your select dependency
$html="<select......."
echo $html;
}
Into this the_url_of_your_ajax_controller you build the second select and echo to the ajax_target div


Messages In This Thread
Update a Select with onchange of other Select - by El Forum - 11-19-2008, 06:57 PM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 01:29 AM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 03:27 AM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 04:34 AM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 07:58 AM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 08:10 AM
Update a Select with onchange of other Select - by El Forum - 11-20-2008, 11:52 AM



Theme © iAndrew 2016 - Forum software by © MyBB