I need a triple drop down menu that populates itself automatically from a mysql database as the options are selected (using ajax and php). (something like this one [login to view URL] ). Before I go any further please note that it is very important to me that THE CODE IS SIMPLE AND WELL COMMENTED. I don't want thousands of lines with no comments. If you don't think you can do that please don't apply for this job.
Also the menu should be “sticky”. In other words, if the user submit the form but the command is not executed (say because some compulsory fields have not been not entered), the selections made by the user should “stick”.
The first menu will be called “Towns”. Once one or more “towns” are selected from the Towns menu the second menu “Districts” will populate (with all the districts belonging to the towns selected). Once one or more “districts” are selected from the District menu the third and last menu “Areas” will populate (with all the areas belonging to the districts selected). So.
Towns
Districts
Areas
The datas will be taken and inserted in mysql tables through php code (I know how to do that).
The data to populate the 3 drop down menu will be taken by the tables “towns”, “districts” and “areas”.
I will be using the menu in two different way:
1. First method (single selection): The user can select only one town, only one district and only one areas (if available and if he chooses to) and the data will be inserted in the table “properties”.
2. Second method (multiple selection): The user must be able to select more than one town or district or areas. His selection will be inserted in the following tables: ” inquiries_town” , ” inquiries_district” and ”inquiries_area”.
As I said I have already prepared the php queries to extract / insert the data in the tables.
All the tables (with some example data) are below:
CREATE TABLE IF NOT EXISTS `towns` (
`town_id` tinyint(4) unsigned NOT NULL AUTO_INCREMENT,
`town_name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`town_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=39 ;
--
-- Dumping data for table `towns`
--
INSERT INTO `towns` (`town_id`, `town_name`) VALUES
(2, 'Scandicci'),
(1, 'Firenze');
CREATE TABLE IF NOT EXISTS `districts` (
`district_id` tinyint(4) NOT NULL AUTO_INCREMENT,
`town_id` tinyint(3) unsigned NOT NULL DEFAULT '0',
`district_name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`district_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=60 ;
--
-- Dumping data for table `districts`
--
INSERT INTO `districts` (`district_id`, `town_id`, `district_name`) VALUES
(1, 1, 'Centro Storico'),
(2, 1, 'Ferrucci e Gavinana'),
(3, 2, 'Giovicchi'),
(4, 2, 'Giovecchiami');
….........................................................................................................................
CREATE TABLE IF NOT EXISTS `areas` (
`area_id` tinyint(4) unsigned NOT NULL AUTO_INCREMENT,
`district_id` tinyint(4) NOT NULL DEFAULT '0',
`area_name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`area_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=16 ;
--
-- Dumping data for table `areas`
--
INSERT INTO `areas` (`area_id`, `district_id`, `area_name`) VALUES
(1, 1, 'Duomo (Centro Storico)'),
(2, 1, 'Santa Maria Novella (Centro Storico)'),
(3, 1, 'San Lorenzo (Centro Storico)'),
(4, 3, 'Giovazzi'),
(5, 3, 'Giovazzoni');
CREATE TABLE IF NOT EXISTS `properties` (
`town_id` tinyint(4) unsigned NOT NULL DEFAULT '0',
`district_id` tinyint(4) unsigned NOT NULL DEFAULT '0',
`area_id` tinyint(4) unsigned NOT NULL DEFAULT '0',
`administrator_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`pr_id` smallint(6) NOT NULL AUTO_INCREMENT,
`owner_id` tinyint(4) NOT NULL DEFAULT '0',
`manager_id` tinyint(4) NOT NULL DEFAULT '0',
`manager_deputy_id` tinyint(4) NOT NULL DEFAULT '0',
`registration_date` date NOT NULL DEFAULT '0000-00-00',
`pr_type` tinyint(4) NOT NULL