Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- view
- -------
- $('#source_type').change(function(){
- $.ajax({
- type: 'POST',
- data: 'source_ref'+$(this).val(),
- url: "<?php echo base_url('documents/get_sources_location'); ?>",
- success: function(data) {
- $('#source_location').val(data);
- }
- });
- });
- controller
- ------
- public function get_sources_location()
- {
- $source_type = $this->input->post('source_ref');
- $this->load->model('documents_model');
- $results = $this->documents_model->get_locations();
- echo json_encode($results);
- }
- model
- ------
- public function get_locations()
- {
- $query = $this
- ->db
- ->select('location')
- ->where('classification', $this->input->post('source_ref'))
- ->get('sources_location');
- $data = array();
- foreach ($query->result() as $row)
- {
- $data = $row->location;
- }
- return $data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement