This is a simple tutorial on how to get a dropdown list value using simple ajax and php
Create a html page named country.html and add the below codes,
HTML CODE
<select name="country" onChange="getCurrencyCode('find_ccode.php?country='+this.value)">
<option value="">Select Country</option>
<option value="1">USA</option>
<option value="2">India</option>
<option value="3">Uk</option>
</select>
<input type="text" name="cur_code" id="cur_code" />
Javascript CODE
function getCurrencyCode(strURL)
{
var req = getXMLHTTP();
if (req)
{
//function to be called when state is changed
req.onreadystatechange = function()
{
//when state is completed i.e 4
if (req.readyState == 4)
{
// only if http status is "OK"
if (req.status == 200)
{
document.getElementById('cur_code').value=req.responseText;
}
else
{
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
Now create a PHP file named code.php and add the below codes,
< ?php
$country=$_REQUEST['country'];
switch($country)
{
case "1" :
echo "USD";
break;
case "2" :
echo "Rupees";
break;
case "3" :
echo "Pound";
break;
}
?>
THATS IT!!!!!!!!!!!!!!!!
As you can see its pretty simple to understand this tutorial.
Incoming search terms:
- ajax drop down list of country by letter in php (59)
- ajax get textbox value (35)
- Changing textbox value from dropdown list using Ajax and PHP (31)
- Change dropdown list (options) values from database with ajax and php (11)
- get textbox value in ajax (10)
- ajax get dropdown value (9)
- Two related drop down list by using Ajax & PHP (8)
- ajax get dropdownlist value (6)
- get textbox value in php (6)
- get value using ajax (6)
- how to get value using ajax (6)
- ajax textbox value (5)
- get textbox value ajax (5)
- onchange dropdownlist populate text field using jquery ajax php mysql (5)
- ajax show drop down text and value (4)
- Get textbox value in the Same JSP Page (4)
- get value of textbox in ajax (4)
- get value through ajax (4)
- how to get dropdown value in textbox (4)
- how to get value of textbox in ajax (4)
- select option click in display value in textbox ajax and php database (4)
- textbox value from drop down list in html (4)
- access the value of next to current page using ajax php (3)
- add value in dropdownlist through database in php (3)
- ajax code for add text box in jsp (3)
- ajax for get value of drop down (3)
- ajax get value of textbox (3)
- ajax mysql 3 drop down menu (3)
- ajax read textbox value (3)
- ajax textbox select database values (3)
- ajax value in textbox (3)
- autocomplete jquery search box from mysql dababase value in yii (3)
- copy value from textbox to drop down menu using php and jquery (3)
- dropdown in textbox by using ajax php mysql (3)
- for loop text box values in jquery (3)
- get textbox value in same page using php (3)
- get textbox value using php (3)
- getting the value in dropdown through textbox php (3)
- getting values from db using dropdownlist in php with ajax (3)
- how to find textbox value in xml file using javascript (3)
You will also be interested in ,
- How to create random passwords using php
- HTML E-mail Using PHP
- Simple Example Of Database Connection Using PEAR In PHP
- Login to yahoo using cUrl in php
- Speed up wordpress using .htaccess part 1
- To Remove An Empty Element From An Array Using PHP
- Convert Month Name To Month Number Using Simple php
- Find the string and then the line number using php from text file
- Exclamation mark (!) at odd places while using php mail fixed
- Import large files in mysql using PhpMyAdmin

