473,322 Members | 1,846 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.

dependent select menus

I would like to create a form in which a 2nd select box appears
depending on the value selected in the 1st select box. The values of
the 2nd select box will come from a database.

My question is how to create this in php? One way is to re-load the
page depending on what's chosen in the first box, or alternatively to
use frames or an iframe?

Is there another, better way that can dynamically change the initial
page?

Jan 23 '07 #1
2 2327
ab**********@yahoo.com wrote:
I would like to create a form in which a 2nd select box appears
depending on the value selected in the 1st select box. The values of
the 2nd select box will come from a database.

My question is how to create this in php? One way is to re-load the
page depending on what's chosen in the first box, or alternatively to
use frames or an iframe?

Is there another, better way that can dynamically change the initial
page?
The way to do this without reloading the page is with Ajax and
javascript. When the user makes the first selection, the page makes a
call to the server which sends back the 2nd set of selections, which can
then be plugged into the second selection box.

The script on the server can be written in PHP. It can send back a
javascript array with the new set of selection values. I would suggest
creating an empty javascript array in the original page and then
populating it with the results returned from the server.

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
Jan 24 '07 #2

<ab**********@yahoo.comschreef in bericht
news:11**********************@l53g2000cwa.googlegr oups.com...
>I would like to create a form in which a 2nd select box appears
depending on the value selected in the 1st select box. The values of
the 2nd select box will come from a database.

My question is how to create this in php? One way is to re-load the
page depending on what's chosen in the first box, or alternatively to
use frames or an iframe?

Is there another, better way that can dynamically change the initial
page?
You could use Javascript to either
a) hide all select boxes except the one corresponding to the choice (by
editing the display property), and have the PHP script generate a SELECT for
each possible choice with "display: none" set by default
b) have the PHP generate a Javascript which will clear the second box and
re-fill it with the appropriate entries onChange of the first select

I think you need Javascript one way or another, if you want to get around
reloading the page (whether it be the main page or an (i)frame).

Regards

Michael
Jan 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rich | last post by:
We are preparing a page with twelve (12) drop down option/select menus, arranged vertically. It works, and it is what the user needs. The widths of the menu boxes are random now, but is there...
1
by: paakwesi | last post by:
I'm looking to modify the javascript behavior on http://research.yale.edu/%7Ekamusi/exercises/learners/index.php to do two things: Initial State: Both menus are populated with all their entries...
6
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets...
3
by: rhamlin | last post by:
I'm fairly new to creating complex sql statements and need a little help. In plain english I want to do this: Select menu rows where the row's userGroupIDs equal the user's userGroupIDs. ...
9
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and...
3
by: abracad_1999 | last post by:
I would like to create a form in which a 2nd select box appears depending on the value selected in the 1st select box. The values of the 2nd select box will come from a database. My question is...
48
by: coool | last post by:
Hi I'm now trying to have a dependent lists in a form my form is a query based form i.e. I fill my MySQL query from this form I have around 30 fields/columns
6
by: dbuchanan | last post by:
There are three parts to this 1.) How do I cascade menus? 2.) And, how do I cascade menus with a multi-select CheckBoxList?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: 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.