|
||||||
| Tutorials Programming Tutorials - Post your tutorials here! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
One AJAX tool popularized by Google is Google Suggest, and all that is required is a basic modification to the code in the previous tutorial. Lets assume we have a php file that connects to a database that contains all the names of the countries. We are also assuming that the php script is setup to receive a GET variable named $country.
Lets start with the basic AJAX code derived from the previous tutorial, but I'm going to change a few variable names and allow it to accept a parameter. JavaScript Code:
Lets assume we have a form that looks like this: HTML4Strict Code:
What we are going to do, is take the value in the "country" input box and submit it to countries.php which will query the database and return the countries related to the name we typed thus far. JavaScript Code:
And thus, we will change our html form to this: HTML4Strict]<form name="suggestform">
Country: <input type="text" name="country" onkeyUp="suggest(this.value)" /> Suggested Country: <input type="text" name="suggestCountry" /> </form>[/code] The final code will look like this: [highlight="HTML4Strict Code:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall Last edited by John; 09-23-2007 at 10:20 PM. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AJAX: Intro | John | Tutorials | 1 | 11-07-2007 08:52 PM |
| Considering Ajax, Part 1: Cut through the hype | Ronin | JavaScript and CSS | 0 | 12-13-2006 02:36 PM |
| Myth-Busting AJAX (In)security | Jordan | AJAX | 1 | 12-03-2006 01:21 PM |
| AJAX Evolved | Jordan | JavaScript and CSS | 0 | 09-09-2006 01:12 PM |
| More AJAX Resources | NeedHelp | JavaScript and CSS | 2 | 07-13-2006 12:57 PM |
| satrian | ........ | |
| jackluxford | ........ | |
| gamiR | ........ | |
| Fred@eisfi | ........ | |
| MeTh0Dz|Reb0rn | ........ | |
| gamers2000 | ........ | |
| gaylo565 | ........ | |
| chili5 | ........ | |
| CharlesHutchsky | ........ | |
| aurelABHR | ........ |
Goal: 100,000 Posts
Complete: 67%