Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Jquery:
- $("#venuecity_country").autocomplete("<?php echo base_url(); ?>venue/get_city_country/",{
- //width: 480,
- matchContains: true,
- minChars: 1,
- onItemSelect:selectItem
- });
- function findValue(li) {
- console.log(li);
- var sValue = li.value;
- $('#event-search-results-content').ngsearch({location:true,locationValue:sValue});
- }
- function selectItem(li) {
- findValue(li);
- $("#city_country").val('');
- }
- Controller:
- function get_city_country()
- {
- $query = $this->Venue_Model->get_city_county($this->session->userdata('venue_cntry'));
- if(!empty($query))
- {
- foreach ($query as $row) {
- echo $row['city'].','.$row['country_name']. "n";
- }
- }
- else
- {
- $get_country = $this->Venue_Model->getLocationInfoByIp($_SERVER['REMOTE_ADDR']);
- $query = $this->Venue_Model->get_city_county($get_country);
- if(!empty($query)) {
- foreach ($query as $row) {
- echo $row['city'].','.$row['country_name']. "n";
- }
- }
- }
- }
- Model:
- function get_city_county($session_country)
- {
- $this->db->select('world_cities.country,world_cities.city,world_countries.country_name,world_countries.country_code');
- $this->db->join('world_countries','world_countries.country_code = world_cities.country');
- $this->db->where('world_countries.country_name',$session_country);
- $this->db->or_where('world_countries.country_id',$session_country);
- $this->db->or_where('world_countries.country_code',$session_country);
- $query = $this->db->get('world_cities');
- if(!empty($query))
- {
- return $query->result_array();
- }
- }
- function get_city_county($session_country)
- {
- $this->db->select('world_cities.country,world_cities.city,world_countries.country_name,world_countries.country_code');
- $this->db->join('world_countries','world_countries.country_code = world_cities.country');
- $this->db->where('world_countries.country_name',$session_country);
- $this->db->or_where('world_countries.country_id',$session_country);
- $this->db->or_where('world_countries.country_code',$session_country);
- $this->db->limit(10);
- $query = $this->db->get('world_cities');
- if(!empty($query))
- {
- return $query->result_array();
- }
- }
- $("#venuecity_country").autocomplete("<?php echo base_url(); ?>venue/get_city_country/",{
- //width: 480,
- matchContains: true,
- minChars: 1,
- onItemSelect:selectItem,
- open: function (event, ui) {
- $('<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');
- }
- });
- function findValue(li) {
- console.log(li);
- var sValue = li.value;
- $('#event-search-results-content').ngsearch({location:true,locationValue:sValue});
- }
- function selectItem(li) {
- findValue(li);
- $("#city_country").val('');
- }
Add Comment
Please, Sign In to add comment