473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to create a dependent drop down box ?

I have created a dropdown box which is populated by data from the mssql server database connected using ODBC. Now i need to populate another dropdown box which will also be from the database but will be based on the value selected in the already created dropdown box. The following is how i have created a dropdown box,

[php]
$sql_visitor= "SELECT DISTINCT Contained FROM IAIS_Ubisense";
$rs3=odbc_exec($connection,$sql_visitor);
echo "<select name=\"name\">";
echo "<option size =30 selected>Select</option>";
if(odbc_num_rows($rs3))
{
while(odbc_fetch_row($rs3))
{
$visitor=odbc_result($rs3,"Contained");
echo "<option>$visitor</option>";
}
}
else
{
echo "<option>No Names Present</option>";
}
[/php]

now i need to get the value from the selection made in the above dropdown box, so that i can use it to create a dependent dropdown box. Please help me in this regard.
May 8 '08 #1
3 6197
ronverdonk
4,258 Expert 4TB
You'll have to use a combination of PHP and JavaScript (Ajax) to accomplish this.
Instead of explaining the whole process, it is better to point you to some tutorials on the subject of populating consecutive drop down boxes dynamically from MySQL using Ajax. These are

Ajax Cascading Drop-down Example
AJAX chained select

Ronald
May 8 '08 #2
You'll have to use a combination of PHP and JavaScript (Ajax) to accomplish this.
Instead of explaining the whole process, it is better to point you to some tutorials on the subject of populating consecutive drop down boxes dynamically from MySQL using Ajax. These are

Ajax Cascading Drop-down Example
AJAX chained select

Ronald
Is it possible to accomplish the cascading drop down list by reloading the webpage. If yes, how ?
May 9 '08 #3
rpnew
188 100+
Is it possible to accomplish the cascading drop down list by reloading the webpage. If yes, how ?
Hi,
It is possible. When you are changing the content of first drop down box submit the page with its value to same page. Then check for that value, load it in first box and load data accordingly in second box.

Regards,
RP
May 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Arpan | last post by:
An ASP application retrieves the DISTINCT records from all the columns of a SQL Server DB table & populates them in drop-down lists. The no. of drop-down lists on the web page depends upon the no....
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
2
by: gk | last post by:
i want to have 2 dpendent drown box. one for country , and the other for city. if you change country in box1 , the city list will also change in box2.. How to do it in javascript ? can...
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
5
by: ashok893 | last post by:
I'm using two drop down list ina form. I have generated the first drop down list from MySQL database. When i select an option from first drop down list, i have to generate second drop down list...
2
by: RAM | last post by:
I need to have two drop down lists in a edited row of a data list. One drop down list should contain Groups and the second one should contain Materials from *selected* group. Thus, I have written:...
5
by: rodeoval | last post by:
I need to have three drop down lists, but the dependent should get the values from the database without refreshing the page..If knows,someone pls reply soon
1
by: sbettadpur | last post by:
Hi, Iam completely new to ajax, I have a task which is 3 dependent dropdowns which are generates automatically from three deferent databases tables based on one another table. example 1.country...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.