Guest User

Untitled

a guest
Jul 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. Jquery:
  2. $("#venuecity_country").autocomplete("<?php echo base_url(); ?>venue/get_city_country/",{
  3. //width: 480,
  4. matchContains: true,
  5. minChars: 1,
  6. onItemSelect:selectItem
  7. });
  8.  
  9. function findValue(li) {
  10. console.log(li);
  11. var sValue = li.value;
  12.  
  13. $('#event-search-results-content').ngsearch({location:true,locationValue:sValue});
  14. }
  15.  
  16. function selectItem(li) {
  17. findValue(li);
  18. $("#city_country").val('');
  19. }
  20.  
  21. Controller:
  22. function get_city_country()
  23. {
  24. $query = $this->Venue_Model->get_city_county($this->session->userdata('venue_cntry'));
  25. if(!empty($query))
  26. {
  27. foreach ($query as $row) {
  28. echo $row['city'].','.$row['country_name']. "n";
  29. }
  30. }
  31. else
  32. {
  33. $get_country = $this->Venue_Model->getLocationInfoByIp($_SERVER['REMOTE_ADDR']);
  34. $query = $this->Venue_Model->get_city_county($get_country);
  35. if(!empty($query)) {
  36. foreach ($query as $row) {
  37. echo $row['city'].','.$row['country_name']. "n";
  38. }
  39. }
  40. }
  41. }
  42.  
  43. Model:
  44. function get_city_county($session_country)
  45. {
  46. $this->db->select('world_cities.country,world_cities.city,world_countries.country_name,world_countries.country_code');
  47. $this->db->join('world_countries','world_countries.country_code = world_cities.country');
  48. $this->db->where('world_countries.country_name',$session_country);
  49. $this->db->or_where('world_countries.country_id',$session_country);
  50. $this->db->or_where('world_countries.country_code',$session_country);
  51. $query = $this->db->get('world_cities');
  52. if(!empty($query))
  53. {
  54. return $query->result_array();
  55. }
  56. }
  57.  
  58. function get_city_county($session_country)
  59. {
  60. $this->db->select('world_cities.country,world_cities.city,world_countries.country_name,world_countries.country_code');
  61. $this->db->join('world_countries','world_countries.country_code = world_cities.country');
  62. $this->db->where('world_countries.country_name',$session_country);
  63. $this->db->or_where('world_countries.country_id',$session_country);
  64. $this->db->or_where('world_countries.country_code',$session_country);
  65. $this->db->limit(10);
  66. $query = $this->db->get('world_cities');
  67. if(!empty($query))
  68. {
  69. return $query->result_array();
  70. }
  71. }
  72.  
  73. $("#venuecity_country").autocomplete("<?php echo base_url(); ?>venue/get_city_country/",{
  74. //width: 480,
  75. matchContains: true,
  76. minChars: 1,
  77. onItemSelect:selectItem,
  78. open: function (event, ui) {
  79. $('<li class=""><a href="#" id="see_more" class="ui-corner-all" tabindex="-1"><span class="label">See More Result</span></a></li>').appendTo('ul.ui-autocomplete');
  80. }
  81. });
  82.  
  83. function findValue(li) {
  84. console.log(li);
  85. var sValue = li.value;
  86.  
  87. $('#event-search-results-content').ngsearch({location:true,locationValue:sValue});
  88. }
  89.  
  90. function selectItem(li) {
  91. findValue(li);
  92. $("#city_country").val('');
  93. }
Add Comment
Please, Sign In to add comment