Ajax Triple Dropdown With Country - Region - Cities?

Mar 17, 2010

Ajax triple drop-down with country-region-cities, all of the 3 drop down menu will got their value form 3 different tables on one db,vthe third drop down is based on the second selection,and also the second one is base on the first one and the problem with the code i have is: there is $val which will keep what is selected,unfortunately $val will just keep the selection of the first drop down,i mean country is the first one so if the choice is usa the $val will be usa,but i want to have each drop down menu selection in separate variable,

i attached the code
Attached File(s)
a.php (1.24K)
Number of downloads: 186
b.php (1.54K)
Number of downloads: 171


Dropdown With Ajax / Get List Of Cities Populated From The Database But Getting A Blank Dropdown?

Apr 26, 2009

For some time i am battling to solve this problem but iam not coming to any conclusion so thought to seek some help here. The problem is that i am getting a blank dropdown instead i should get list of cities populated from the database. Database connection is fine but iam not getting anything in my dropdown.

This is what iam doing:


require 'includes/connect.php'; - database connection
$country=$_REQUEST['country']; - get from form (index.php)
$q = "SELECT city FROM city where countryid=".$country;
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if ($result) {
<select name="city">
<option>Select City</option>
$id = 0;
<?php while ($row = $result->fetch_object()) {
$src = $row->city;
$id = $id + 1;
<option value= <?php $id ?> > <?php $src ?></option>
<?php } ?>
<?php } ?>

ajax script is this:

function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{mlhttp=new XMLHttpRequest();}
try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); }
catch(e){ try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
return xmlhttp;
function getCity(strURL) {
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
} else {
alert("There was a problem while using XMLHTTP:
" + req.statusText);
req.open("GET", strURL, true);

This is my form code:

<form method="post" action="" name="form1">
<table width="60%" border="0" cellspacing="0" cellpadding="0">
<td width="150">Country</td>
<td width="150"><select name="country" onChange="getCity('findcity.php?country='+this.value)">
<option value="">Select Country</option>
<option value="1">New Zealand</option>
<option value="2">Canada</option>
<tr style="">
<td ><div id="citydiv"><select name="city">
<option>Select City</option>

View 2 Replies View Related

Social Engine Zend Framework - Dynamic Ajax Dropdown For Country / State / City?

Oct 21, 2010

I am working with Social Engine which is based on Zend Framework and Smarty Templates. I need to make custom functionality for profile page, where I need Ajax based Dynamic Country / State / City selections like

Dropdown for Country -> on selection of some country, State will display belonging to selected country and State selection -> related Cities will display. I have separate tables for my country/state and city.

can provide some reference / examples for the same? I don't know, how to make Ajax calls and render my views with this !

View 2 Replies View Related

Automatically Populate Cities With Respect To Selected Country?

Jun 28, 2011

I am trying to extend shipping method with respect to cities.

When i select country in flat rate, Automatically populate cities with respect to selected country.

How may i change or extend shipping method

View 2 Replies View Related

Populate Country / Region Names At DB Or Application Level?

Jan 9, 2011

My website would have a list of countries in dropdown list and list of cities based on chosen country. I decided to populate the list at db level as:

countryID - PK
countryName - FK


cityName gets inserted directly without us having to join or call multiple tables and get specific ID for a city so we can then grab the cityName, etc...

I will only normalize in crucial tables such as making relationships between Member and Post/Thread tables. A member can have multiple threads one-to-many relationship. Otherwise, things that relate to multi-value as countries list won't be considered at DB level for simplicity and rap sake.

View 3 Replies View Related

Populate A Dropdown List Of All Unique Cities From A Table In Database?

Apr 5, 2011

I am trying to populate a dropdown list of all unique cities from a table in my database. Some users have the same city and when I populate the dropdown list, I get cities multiple times. This is not what I want. Just once is enough.

Here is what I have...

$query = mysql_query("SELECT city FROM users");
echo "City <select name='city'>";
while ($row=mysql_fetch_array($query))
if ($row['city']) some users do not have a city


View 4 Replies View Related

Loading Cities Combo Using AJAX And It

Dec 25, 2010

I am trying to load city combo using AJAX and PHP.....but its showing nothing... This is AJAX

HTML Code:
// JavaScript Document
// JavaScript Document
var xmlHttp
// Start of loading Constituency //
function loadcity(state_search)
var value=document.getElementById('inpstate').value;
//var lang=document.getElementById("language").value;

View 1 Replies View Related

Dropdown Selected Value From Database / Display Selected Value Of Country Dropdown List As Value Saved In Db?

May 27, 2010

In edit profile form I want to display selected value of Country dropdown list as value saved in db and user can change that also.

View 4 Replies View Related

Select Country From Dropdown From Saved Search

Jan 17, 2011

I have a search form where users can search by age and country. Users can also save their search so they can go back and do it again but the problem is when they reload their saved search, I need it to select the country that has been saved in the drop down. So if someone searched the United Kingdom, I need it to show United Kingdom in the select drop down instead of (Select Country). Is there any easy and quick way around this?

View 3 Replies View Related

HTML Show Dropdown Of Country Calling Codes?

Jul 7, 2010

I need to show a dropdown menu with the international calling codes for each country. Where can I find such a drop down????

View 5 Replies View Related

Pick A Country Dropdown Selection Form Item Without Using Database?

Jul 24, 2009

I have this PHP code that I use to make a dropdown form selection of country'sI would like to eliminate this extra mysql query though and just store the output like in code to on the pageHowever I am lost on how I would have the users country SELECTED If I do not use the query to get the data

<select name="country" style="width:180px;" onChange="do_get_rest_popup(this.value)" o>
$sql="SELECT * FROM users_countries ORDER BY country";


View 3 Replies View Related

Make Timezone Dropdown List Populate With Available Timezones On A Per Country Basis?

Jan 25, 2010

I just noticed something really nice on the Google Analytics signup page for adding a new domain. First you pick a country them you pick your timezone. Instead of showing a huge Timezone list though they populate the timezone list with only timezones that are available for the country you have selected. I think this is a great idea to make picking a timezone easiar for some users.

So I would like to do this with jQuery since most my other javascript is using jquery already. Has anyone seen any existing jquery script that can do this for me? Or possibly how I can figure out what timezones are in each country?

View 2 Replies View Related

Select A Region From A Picture And Blur The Selected Region And Make It Watermarked ?

Jan 10, 2011

I tried a lot but cannot find it out.. I have found watermarked script. But i did n't find a script where i can select a region from a picture and blur it..

I am using PHP Script for that.

View 1 Replies View Related

Form Country List - Recording The Users Country To The Database

Sep 14, 2009

I am making a very simple form which will input information into a mysql database to make a user account. However, I am having difficulty in recording the users country to the database. I am using the following code to generate a drop down list for country selection. -

<select><option value=" " selected>(please select a country)</option><option value="--">none</option><option value="AF">Afghanistan</option><option value="AL">Albania</option><option value="DZ">Algeria</option>etc etc

how to record the user's selection to a table in my database, as google searches have proven to be a little daunting!

View 5 Replies View Related

Calling Dropdown Through Ajax?

Oct 2, 2010

i want to show dropdown box calling from another dropdown. when one is selected, another dropdown will be called from database values. i am using this code :

echo $fginfo=" <td width='150' class='label'>Items</td>
<td class='content' colspan='3'>
<select name='item_code' id='item_code' onchange='checkitemcode();'>
<option value='0'>Select Item</option>".


but the values from the database are not seen.

View 1 Replies View Related

Using AJAX To Populate Dropdown Menu?

Oct 21, 2008

I want to allow users to update a school dropdown menu without the page refreshing. The schools would be added to MySql and then retrieved using PHP and AJAX to populate the menu.

Here is what the HTML would look like:

HTML4Strict Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script type="text/javascript" language="javascript">function populate(){if (document.form1.select.value !=


View 6 Replies View Related

Filtering Dropdown Menu's With Ajax ?

Jan 20, 2011

I have a CodeIgniter MVC application. I have a model called city that has a method:

class Cities_model extends Model{
function Cities_model(){
function get_cities($id = null){
$this->db->select('id, city_name');


So it is successfully retriving the correct data. the only problem is it's adding blank values/text to the drop down. and each time I change the city the data is being added on, so I guess i'd have to clear the dropdown first?

View 2 Replies View Related

Populate Multiple Dropdown From DB Using AJAX?

Sep 27, 2010

I am working on a car portal and having a problem in populating multiple dropdown from database using PHP and AJAX. For example,I have 1st drop down of CAR MAKE which has 3 car companies names (Filled from databse)

1. Toyota

2. Honda

3. Nissan

Then I have another dropdown which which will populate on selecting the above described CAR MAKE dropdown.

1. Corolla (for Toyota)

2. Civic (for Honda)

3. Skyline (for Nissan)

(e.g If I select Toyota then automatically in the next dropdown corolla will appear and so on)

Then I have another dropdown by the name of PRICE which will have car price (e.g Min price 10,000 to Max 100,000,000)And at last I have a search button which will take me to the search page of my selected values in the above 3 dropdowns and will show a list of cars from database.

View 2 Replies View Related

Triple Menu

Apr 18, 2007

I'm going to have a website that will have a very dynamic menu structure (one that could change every few minutes) and it is essential that everytime the menu is built, the updated database entries are included.

Background:  The site is a homework study site that gives study tools, etc.  So lets say that i want to look up the Math (subject or "class"), Pre-Algebra ("course"), CPM ("curriculum"), i would first select Math in the first drop down menu, then Pre-Algebra in the second, and then CPM in the third.  In the second and Third boxes however, there will be other courses and curriculums to choose from.  Those will be updated very regularly and i do not want to do this manually. Code:

View 1 Replies View Related

Triple Form

Aug 6, 2007

I'm writing a single page form which gives the user the options to add, edit, or delete items from a database table. I wish to have this page post to itself, and have all the three options in the one form.

View 2 Replies View Related

Encryption Using Triple DES

Mar 6, 2007

currently i am working on a project where we are encrypting a string using triple DES. this encrypted is used for decryting in VC++(this is done by the client) can anyone tell me different ways of performing triple DES encryption.

View 4 Replies View Related

Hide Current Country From A Country Selector

Apr 7, 2011

We have multiple Wordpress sites running on the same framework/markup with the exact same functions to simplify updates. Now I want to add a country selector where all sites are added manually in a template file. BUT, I want the current country flag hidden.

Code sample:......................

I'm thinking of a solution based on the site title: bloginfo(name); If the current site title is "Name 2" and "Name 2" exists in the "makeItem list", it get's removed. Is that possible?

View 1 Replies View Related

6 Dropdown Boxes Populated From It / MySQL Using Ajax

Feb 7, 2007

i want to use a dropdown box to populate another dropdownbox and so on but i want to maitain all the data adt was selected from d previoce box and i dnt want to make use of submit button but the dropdown must triger the changes assoon as its value gange

View 41 Replies View Related

Jquery - Ajax Dropdown Table Sorting?

Jun 7, 2011

I have a page which has a dropdown box. On selection a value is sent to a php script (Ajax), based on the value a html table is created and sent back to the responseText. The table is output to the HTML page.I want the table to have sortable columns, so I have used jQuery datatables for this, but it is not working.I have cut and pasted the exact table into the html and ran the page, and then sorting works.

Note the table output from the php is outputted inbetween:

<a div id="txtHint"> <table id="example"> <div>

Here is the rest of the code on the HTML page:

<script type="text/javascript" src="/js/jquery-1.5.1.js"></script>
<script type="text/javascript" src="/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">[code]....

View 1 Replies View Related

RDF Triple Visualizer - ARC2?

Mar 8, 2010

any good software for visualising an rdf triple store as an actual graph? I am using an arc2 triplestore and have already tried the visualizer plug in that is available from semasols site but I cant get it to work: I keep getting theis error: XML Parsing Error: no element found Location:

data:image/svg+xml;base64, Line Number 1, Column 1: I think that the software (Graphviz) isnt linking up with the store somehow but cant work it out. I would have assumed that there would be some sort of api that you could use for this sort of thing but I cant find anything.

View 1 Replies View Related

Call AJAX Request On Dropdown Change Event ?

Aug 7, 2010

<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="ajax.js"></script>

Above code is working perfectly. When I click link 'One' then String 'One' is loaded into workspace DIV and when I click link 'Two' then String 'Two' is loaded into workspace DIV.Question:Now I want to use a dropdown to load one.php and two.php in workspace DIV instead of links in index.php. When I use link then I use class='ajax' in link properties but how to call ajax request on drop down change event ?

View 2 Replies View Related

Jquery - Changing Dropdown List Values Using Ajax?

Jun 22, 2011

Populating dropdown - PHP Ajax MySQL

I have 4 dropdown list elements and they should be combined with each other, its about destinations. the first one should have all destinations and then depending on what the user selects the second dropdown list with have the values(destinations) that are available for the selected city, then the 2 other dropdown lists will have the opposite way of that destination. its something like the form in this web site: [URL] (you can see the example in the left side there is a bookig form). I need the ajax script to do this. I will take care of the PHP task.

<div class="WraperForForm">
<form action="index.php?menu=rezervimet&submenu=rezervo" method="post">
<table cellspacing="5" cellpadding="0" border="0" >
<td width="100">


this is part of the code, when I started it I forgot that people will be able to make reservation from cities near them or from abroad, so I made the FROM dropdown only with the domestic cities and the TO dropdown list with foreign cities. anyway I need all this with ajax because I am not good at all with ajax!

View 3 Replies View Related

Make Dynamic Dropdown Lists Using It / MySQL / AJAX

Feb 24, 2011

I am trying to make three dynamic drop down lists. When I say dynamic I mean when I choose a value from the first one, the second one changes options and when I choose a value from the second one then the third one changes options. But at the end I want the to keep the selected values because I will submit them. For example the first list may be Country, the second one may be City and the third one Postal Code.

So once I choose country I want the cities in that country to be visible and again once I choose city I want postal code to be visible, buy I do not want to loose my selections every time because I will submit them at the end. I was able to make it up to two drop down menus and it works perfect, but once I add the third everything is destroyed.

<!doctype html public "-//w3c//dtd html 3.2//en">  
<title>Multiple drop down list box from plus2net</title>
<SCRIPT language=JavaScript>
function reload(form)

View 2 Replies View Related

Give Triple Value To A Single Column?

Apr 20, 2010

I have 3 drop downs the user can only selected one of them but no matter which drop down user select it has to be inserted into same same field on the database which is field select3 usually is Quote:

$select3 = $_POST['select3'];
i tried to change to
$select3 = $_POST['select1 && select2 && select3'];
and the insert
$query="INSERT INTO photos values ('$select3')";


View 10 Replies View Related

Auto Populate Triple Drop Down Box

Jul 17, 2011

I'm trying to create an ad section on a member website so people can post daily ads like craigslist. but I'm having trouble with the location selection. I found this tutorial online (in the javascript and php below). It autopopulates three drop down boxes based on the country, then state, then city, all from the database tables (country, state, city)...

It works great for populating the dropdown boxes BUT I can't figure out how to take the Country Value from the Form, and the 2 strings retrieved from the DB (Like USA, California, Los Angeles) and put them into my db "dailyads" table (in to the respective fields of course - country, state, city)??


View 6 Replies View Related

Jquery Ajax - On Change Of Dropdown List Showld Call The Function?

May 24, 2011

On change of the dropdown list, A php function should called.Inside the PHP function I will do some calculation. Later I need to set the value of a text box or else that PHP function should return a value that value shoul be catch in the javascript and set that valu to the textbox control.My html function is nd in PHP function is placed in D:/Project/EmployeeDetails/EmpLeave.php

class clsGetTotalPL
function GetTotalPL($EmployeeId)


View 2 Replies View Related

Ajax - Query - Dropdown Menu - Populate The Text Box With Info From DB And Load The Images

Sep 6, 2009

I am working with php and want to have a page that has a drop down on top. elements in the drop down have some id associated with them. Underneath the drop down there is a text box and underneath the text box some images. so like the following

<drop down box>
<textbox _content_ loaded via ajax onchange of drop down box>
<some images loaded via ajax onchange of drop down box>

I want to query the DB everytime the drop down menu is changed and populate the text box with info from DB and load the images that were fetched from the DB. is there some ajax library that can be used for this? I assume there will be a php page to execute the query and send the result back to the main page?

View 5 Replies View Related

Calculate Distance Between Two Country To Country And Country To City And City To City?

Apr 11, 2011

how to calculate distance between two country to country and country to city and city to city ?

View 1 Replies View Related

Dynamically Loading Cities

Jun 13, 2005

I'm looking to make a page that dynamically loads cities according to the country/state selected on the same page. Is there anyway to do this without using javascript? All of the cities/states are stored in a database.

View 4 Replies View Related

List Of Cities And Countries

Jul 30, 2007

I need a list of Major cities and countries (preferably provided in a related manner) for a database. Is there somewhere which provides it preformatted so I can simply enter them all at once into a database rather than having to do it manually.

View 6 Replies View Related

Pass The Selected Option In A Dropdown To AJAX Always Gives The First Option?

Oct 21, 2010

this is my code:

comenzar = function(){
document.getElementById('gene').onclick = xmlhttpPost("generador.php");

View 1 Replies View Related

Ajax Not Working In IE8 On Dropdown But It's Working Fine In FF,CROME And Others?

Mar 23, 2011

My ajax code is working fine in other browsers but in IE it's not working well.It's creating XMLHTTPRequest but the value from my PHP script is only an empty list!Here's my Javascript:

<script type="text/javascript">
function getcity()


View 1 Replies View Related

Output The Time In Various Cities Around The World

Oct 26, 2006

I need some php to output the time in various cities around the world (London, Hong Kong, Bangkok etc), and automatically take account for daylight saving times etc...

Any easy ways to do this? Obviously you can't set the offset manually as it changes from time to time...

View 5 Replies View Related

Calculate The Distance Between Two Cities (Canada)?

Apr 15, 2011

i have a client who wants me to calculate the distance in miles between cities. I am doing project in PHP, javascript , i have been reading about some long/ lat database but still not able to find where to start and what to use for it. Is there any web service i can query by passing two city names and it can return me the distance in miles or km?

View 2 Replies View Related

Countries -> States -> Cities Dropdownlists?

Dec 24, 2009

Database for implementing dropdowns for Countries than based on selected country the States/Proviences dropdown and then the cities dropdown on the bases of selected State/Provience for all the countries in the world.

View 3 Replies View Related

Getting An Array Of Cities Out Of A Json Response?

Jul 8, 2010

I have the following code. I am trying to get just the name of the city out of the feed that is requested, and into a new array.

$city = $_GET['city'];
$json = @file_get_contents('http://ws.geonames.org/searchJSON?country=GB&maxRows=10&name_startsWith=$city');
$json = utf8_encode($json);
$city_suggest = json_decode($json, true);


View 4 Replies View Related

Getting Waypoints Between 2 Gps Coordinates From Cities Table?

May 30, 2011

How could I retrieve a list of cities which are enroute(waypoints) between 2 gps coordinates?

I have a table of all cities, lat-lon. So if I have a starting location (lat-lon) and ending location (lat-lon)... It must be very easy to determine the path of cities (from table) to pass by(waypoints) to get from start(lat-lon) to en (lat-lon)?

View 4 Replies View Related

(OT) Where To Download World List Of Countries And Their Cities?

Feb 6, 2006

I need to populate a database with a list of countries of the world,
along with the cities (cities dosent need to be an extensive list). Does
anyone know where I can download such a file? - to save me having to
manually create such a file from (possibly various sources)?

View 2 Replies View Related

Declare A Two-dimensional Array Of Countries And Cities?

May 25, 2011

I'm making a website that has URLs for each country and city, and name of restaurant.


I know how to do the Apache rewrites for it, The question is how to make it as efficient as possible wuth php.right now what I do is first declare a two-dimensional array of countries and cities:

$countries = array("United-Kingdom"=>array("Bristol","London"),

than I check if the city exists:

if (isset ($countries[$page])

and then i do use the in_array function for the city, the restaurant name is looked up in the database.The array of countries and cities is quite huge, so I want to know if there's a more efficient way of doing this.I though of maybe making a php file for each country and try to include it, and have in each php file the array of cities.and maybe set up a cron job that will update the files.I wondered is the most efficient way of doing this that will use the least processing CPU usage and make the server serve the pages as fast possible.

View 1 Replies View Related

Finding Cities Close To One Another Using Longitude And Latitude?

Jan 11, 2011

Each user in my db is associated to a city (with it's longitude and latitude)

How would I go about finding out which cities are close to one another?

i.e. in England, Cambridge is fairly close to London.

So If I have a user who lives in Cambridge. Users close to them would be users living in close surrounding cities, such as London, Hertford etc.

how I could go about this? And also, how would I define what is close? i.e. in the UK close would be much closer than if it were in the US as the US is far more spread out.

View 6 Replies View Related