0

The issue is what I say in the title. The parameter of the index selected in the first dropdown box is not sent to the controller. Therefore the controller cannot pass any value to the model etc. If I harcode saying $pais_id = 1 and send that to the Model it works, so this means, the issue is in the controller not getting it from the jquery. VIEW

<script type="text/javascript">
//jquery code for source list
$(document).ready(function(){
$('#country').change(function() {
  if ($(this).val()!='') {
    $("#source").load("/CI-3/controllers/control_form.php",{pais_id: $(this).val()});
      }

    });

});  // end of country and city function
</script>

The problem must be there because I don't visualize the process: Jquery detects the changing in the select dropdown list and fetches the selected id. Alright, but what happens next ? it sends it to the controller, yes, and? the controller forwards it to the model, the model does a sql search and returns an array back to the controller and the controller forwards it to the view, but, how does #source in the line above get affected after all that?, so it will not modify itself

1

1 Answer 1

1
$source['source'] = $this->model_form->get_source($pais_id);

should be

$data['source'] = $this->model_form->get_source($pais_id);

in controller. third parameter in view is if it's returned or echo'd. all values are passed in the 2nd parameter as an array.

Sign up to request clarification or add additional context in comments.

4 Comments

thank you, we may be getting closer. yet, note that a few lines above, I already write that I am getting an empty value for $pais_id. $pais_id = $this->input->post('pais_id', TRUE); # echo "the value is es $pais_id"; (I get emptyness
I made an experiment. In the model, if I replace the parameter $pais_id by 1, then all works well. The second select list gets correctly populated. Thus=>all it is needed is that the Model does get that value from $pais_id, not that I hardcode it.
I suggest you learn to troubleshoot this issues. Everything from print_r() in php to console.log() in javascript can help you find what happends to your values. Be a bit creative and just check through the entire code where the values might be missing. If you do it, you're bound to find where the problem lies.
I am doing chest acrobatics with this as I am introducing all kinds of tricks and debugs in order to pin point where the issue is and that is how I have managed to reduce the three modules to this piece of snippet, I have also included call back function in the jquery script to see if anything has been loaded, I do a lot of var_dump and echo and that is how I learned that the value is NOT being passed from the jquery to the controller because it is a false boolean claimed on. etc etc and etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.