Jump to content

Search the Community

Showing results for tags 'cities'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. This is the code for a dynamic dropdown list which i use to create a record. It works. But i find it slow when updating a record. It takes time to load the cities dropdown data. I am wondering, is there a more efficient way to do this dropdown so it loads the data more quickly? <script> function getCity(val) { $.ajax({ type: "POST", url: "../snippets/get_cities.php", data:'state_id='+val, success: function(data){ $("#city-list").html(data); } }); } function getState(val) { $.ajax({ type: "POST", url: "../snippets/get_states.php", data:'country_id='+val, success: function(data){ $("#state-list").html(data); } }); } function selectCountry(val) { $("#search-box").val(val); $("#suggesstion-box").hide(); } </script> <fieldset> <label>Location:</label><br/> <select name="country" id="country-list" onChange="getState(this.value);"> <option value="">Select Country</option> <?php $get_countries = $db->prepare("SELECT * FROM countries2"); $get_countries->execute(); $result_countries = $get_countries->fetchAll(PDO::FETCH_ASSOC); if(count($result_countries) > 0) { foreach($result_countries as $row) { $get_country_id = trim($row['id']); $get_country_name = trim($row['name']); ?><option value="<?php echo $get_country_id; ?>" <?php if($record_country_id == $get_country_id) { echo 'selected'; }; ?>><?php echo $get_country_name; ?></option><?php } } ?> </select> <select name="state" id="state-list" onChange="getCity(this.value);"> <option value="">Select State/Province</option> <?php $get_states = $db->prepare("SELECT * FROM states"); $get_states->execute(); $result_states = $get_states->fetchAll(PDO::FETCH_ASSOC); if(count($result_states) > 0) { foreach($result_states as $row) { $get_state_id = trim($row['id']); $get_state_name = trim($row['name']); ?><option value="<?php echo $get_state_id; ?>" <?php if($record_state_id == $get_state_id) { echo 'selected'; }; ?>><?php echo $get_state_name; ?></option><?php } } ?> </select> <select name="city" id="city-list"> <option value="">Select City</option> <?php $get_cities = $db->prepare("SELECT * FROM cities"); $get_cities->execute(); $result_cities = $get_cities->fetchAll(PDO::FETCH_ASSOC); if(count($result_cities) > 0) { foreach($result_cities as $row) { $get_city_id = trim($row['id']); $get_city_name = trim($row['name']); ?><option value="<?php echo $get_city_id; ?>" <?php if($record_city_id == $get_city_id) { echo 'selected'; }; ?>><?php echo $get_city_name; ?></option><?php } } ?> </select> </fieldset>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.