473,402 Members | 2,072 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,402 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
3 5102


On 23 Jan, 23:47, "abracad_1...@yahoo.com" <abracad_1...@yahoo.com>
wrote:
Is there another, better way that can dynamically change the initial page?
AJAX

Jan 24 '07 #2
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 #3

<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 #4

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...
2
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
2
by: rpeterson84 | last post by:
Hello: I was hoping to gain some insight, a point in the right direction if you will... We use an .asp web page to select from a couple of dynamic drop down menus then enter a number, and press...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.