Click here to get back home

dependent select menus

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
dependent select menus abracad_1999@yahoo.com 01-23-2007
Get Chitika Premium
Posted by abracad_1999@yahoo.com on January 23, 2007, 6:47 pm
Please log in for more thread options


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?


Posted by Andy Dingley on January 23, 2007, 6:57 pm
Please log in for more thread options




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

AJAX


Posted by Myron Turner on January 23, 2007, 9:36 pm
Please log in for more thread options


abracad_1999@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/

Posted by Michael on January 24, 2007, 6:01 am
Please log in for more thread options



>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



Similar ThreadsPosted
sub-menus August 5, 2005, 6:45 am
pulldown menus September 8, 2005, 7:23 pm
Drop down menus February 12, 2006, 4:45 am
best way to markup navigation menus? July 9, 2004, 11:37 pm
Customizable dropdown menus? February 2, 2008, 10:24 pm
Problem with expanding/collapsing menus and NE7 August 26, 2004, 7:04 pm
Frames -- Disable/Enable Menus April 21, 2008, 7:14 am
Help: Adding a banner to a site that uses "flanking menus", and CSS August 19, 2004, 6:00 am
Dropdown menu javascript menus a bad choice? July 22, 2005, 10:06 pm
Create Pulldown Menus for Month/Day/Year in HTA December 29, 2006, 10:31 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap