Ajax triple dropdown
  Ajax triple dropdown - Web Hosting by Hostway
2D Graphics
3D Graphics
Web Design & Development
Business Applications
Business Development
Desktop Programming
Operating Systems
Video Editing
Miscellaneous
Newsletter
User Login
  • Username
  • Password
Stats
  • Tutorials: 27,017
  • Categories: 572

PHP Tutorials : Ajax triple dropdown

This "short" code will populate 3 dropdown in each other. Visit for the source code: http://sfx.site40.net/ajax3.php Go to phpmyadmin, and run this query: DROP TABLE IF EXISTS `location`; CREATE TABLE IF NOT EXISTS `location` ( `id` int(7) NOT NULL auto_increment, `loc_code` varchar(255) default NULL, `loc_abbr` varchar(255) default NULL, `loc_name` varchar(255) default NULL, `location_name` varchar(255) default NULL, `loc_order_name` varchar(255) default NULL, `flag_disaster` char(1) default NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; Create index.php, and lets create three dropdown with PHP \n"; ?> \n"; ?> \n"; ?> /**DO NOT INSERT*/ Lets Use this Javascript, to communicate the .php file called locale.php /**DO NOT INSERT*/ Open a locale.php, and take these lines. /**DO NOT INSERT*/ START \n"; echo "\n"; $result=mysql_db_query($dbname,"select loc_code from location GROUP BY loc_code"); while(list($nomeCategoria)=mysql_fetch_array($result)){ echo " \n" ; } } else if ($data=='subcategoria') { echo "\n"; echo "\n"; $result=mysql_db_query($dbname,"SELECT id , loc_name FROM location WHERE loc_abbr='$val'"); while(list($id, $name)=mysql_fetch_array($result)){ echo " \n" ; } } echo "\n"; ?> /**DO NOT INSERT*/ END OF locale.php For testing lets fill the table with meta data, to be able to test it. The first part of the locale.php is the connection to the database, change according to your host setup. If you select from the dropdown list, that will populate the second one, if you select the second dropdown tht will populate the third one, using the avaiable data from the table's second AND third field. This code is working whithout page refreshing, useful for user details, date-calendar populating, locations managements. You have to change the table select, if you need another one table structure. Notice that this table is not well normalised, becouse the real life is different if you need to make a project in a short time :) if you have to make three dropdown from well designed tables, the first and second dropdown have to be in parent and child relations. Any question in private message, or use the comment box here! Thank you for you audiance! Ajax triple dropdown  tutorial
    View Tutorial

Detailed Information

     Tutorial: Ajax triple dropdown
     Date Listed: 2009-04-30
     Submitted By: djjjozsi
     Total Hits: 2035
     Rating Tutorial Rating 2.71Tutorial Rating 2.71Tutorial Rating 2.71Tutorial Rating 2.71Tutorial Rating 2.71 (24 votes)

    Discuss Tutorial
    Comment On Tutorial
    View Tutorial
    Report Broken Link

 







© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek