Advertisement
Guest User

Untitled

a guest
Feb 25th, 2013
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. view
  2. -------
  3. $('#source_type').change(function(){
  4. $.ajax({
  5. type: 'POST',
  6. data: 'source_ref'+$(this).val(),
  7. url: "<?php echo base_url('documents/get_sources_location'); ?>",
  8. success: function(data) {
  9. $('#source_location').val(data);
  10. }
  11. });
  12. });
  13.  
  14. controller
  15. ------
  16. public function get_sources_location()
  17. {
  18. $source_type = $this->input->post('source_ref');
  19. $this->load->model('documents_model');
  20. $results = $this->documents_model->get_locations();
  21. echo json_encode($results);
  22. }
  23.  
  24. model
  25. ------
  26. public function get_locations()
  27. {
  28. $query = $this
  29. ->db
  30. ->select('location')
  31. ->where('classification', $this->input->post('source_ref'))
  32. ->get('sources_location');
  33. $data = array();
  34. foreach ($query->result() as $row)
  35. {
  36. $data = $row->location;
  37. }
  38. return $data;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement