Automatic dropdown box loading using angularjs
Populate a dropdown2 based on dropdown1 Here i am explaining the code for loading a state dropdown using country dropdown using angularjs and php. Step1:create a database mytest_data and create 2 tables tbl_country and tbl_state. here country table is associated with state table using country_id.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
CREATE TABLE IF NOT EXISTS `tbl_country` ( `id` int(10) NOT NULL, `country_name` varchar(100) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; INSERT INTO `tbl_country` (`id`, `country_name`) VALUES (1, 'India'), (2, 'UAE'); CREATE TABLE IF NOT EXISTS `tbl_state` ( `id` int(10) NOT NULL, `state_name` varchar(100) NOT NULL, `country_id` int(10) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; INSERT INTO `tbl_state` (`id`, `state_name`, `country_id`) VALUES (1, 'Karnataka', 1), (2, 'Kerala', 1), (3, 'Abhudhabi', 2), (4, 'Sharja', 2); |
create the tables using the above code. Step2:create two… Read More »