SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Double Dropdown List Download Script

Dynamic populating three drop down list based on the selected value of first two list

Before reading this please read the dynamic filling of second drop down list with selected value of first list. Here we will work with three drop down lists where the value of second list is populated based on the selection of first list and the values of third drop down list are populated based on the selection of second drop down list.

Now after selecting option for second dropdown list the page reloads by taking the data of first and second dropdown list. This part is done with the help of JavaScript.

function reload3(form)
{
var val=form.cat.options[form.cat.options.selectedIndex].value;
var val2=form.subcat.options[form.subcat.options.selectedIndex].value;

self.location='dd3.php?cat=' + val + '&cat3=' + val2 ;
}

Using the same concept we can extend to add more dropdown list boxes.

Here the page is reloaded on selection of second drop down list and for this the table structure is changed with creation of third table.

If you are facing any problem in using this code, please post it in php discussion forum with your error messages, bugs etc ..

view demo for three dropdown list here


download script
Google+
kiran04-11-2013
i am using 3 dropdown menues, there are three table in my database,these tables are linked with foreign keys,but when i using just like your dd3.php, then 1st dropdown menu lost their value and get default value
also when i getting the selected value in same page using this self.location="reg3.php?Result=" + nam; in javascript, and when i got notice error. please reply as soon as possible..
Aji Mohan Singh10-02-2014
keep the drop down menu value javascript after submitting
Stacey15-08-2014
I am looking for an easy php code
Mark19-11-2014
If I have more than 12 items in the subcategory2 table that link to one item in subcategory table, it will not list them all. Do you know why?
smo19-11-2014
There is no reason why it should not list all 12 items ( if they are linked with category id )
mark20-11-2014
yeah its weird. i had to truncate the table and reenter the values then it started working.
Mark20-11-2014
how does this solution handle duplicate values. I want it to be able to display duplicates if possible.
smo20-11-2014
At the database table the duplicate records are to be handled. You can use distinct command to get only unique records from table and display them as options.
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer