[eluser]alvaroeesti[/eluser]
Hello,
been over a day with this. Somewhere there must be a bug. The second (there are only two) select list does not get altered, thus it gets no value when the first one changes.
Here is the full stuff, long, but very clear and commented:
VIEW
Code:
[removed]
//jquery code for source list
$(document).ready(function(){
$('#country').change(function() {
if ($(this).val()!='') {
$("#source").load("/CI-3/application/controllers/control_form.php",{pais_id: $(this).val()});
}
});
}); // end of country and city function
[removed]
<body>
<?php echo form_open('control_form/add_all'); ?>
<label for="country">Country<span class="red"></span></label>
<select id="country" name="country_names">
<option value="pais_id"></option>
<?php
foreach($result as $row)
{
echo '<option value="' . $row->pais_id . '">' . $row->pais_name . '</option>';
}
?>
</select>
<label for="source">Source Language<span class="red"></span></label>
<!--this will be filled based on the tree selection above-->
<select id="source" name="source_names">
<option value=""></option>
<?php
foreach($source as $row)
{
echo '<option value="' . $row->id_from . '">' . $row->from_name . '</option>';
}
?>
</select>
<?php echo form_close(); ?>
CONTROLLER
Code:
public function add_all()
{
#Validate entry form information
$this->load->model('model_form','', TRUE);
$this->form_validation->set_rules('pais_id', 'Country', 'required');
$this->form_validation->set_rules('source', 'Source language', 'required');
# Populate the first select list by sql querying in the model. (Works well)
$data['result'] = $this->model_form->get_state(); //gets the available countries for the dropdown
# Now this should get the value selected in the first dropdown, sent from the Jquery, in the View
$pais_id = $this->input->get_post('pais_id', TRUE); # but I am not getting anything
I know the rest is OK. The issue is somewhere above