Re: Dynamic pull down menus with PHP/Mysql
| From: | Antoine | Date: | Fri, 08 Oct 2004 16:45:14 +0000 |
| Subject: | Re: Dynamic pull down menus with PHP/Mysql | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36693@lists.php.net to get a copy of this message | ||
On Fri, 8 Oct 2004 01:12:06 -0400, GH <garyhotko@gmail.com> wrote:
> For a project in college that I had once did using ColdFusion and
> MSAccess (please dont kill me :)) I had the simular situation....
>
> What I did was when the First Drop Down was changed... it had an
> onChange action or something of that nature (do not have my exact code
> infront of me) that went to a JS function which sent the value to
> another frame (window) you can use a hidden 1x1 iframe to conduct
> this... it then returned the values to the other page via JS,,,, I
> have to Dig for the code which unfortinately is buried at the
> moment....
>
>
>
>
> On Tue, 5 Oct 2004 08:22:22 -0700, Ed Lazor <ed.lazor@d20news.com> wrote:
> > > -----Original Message-----
> > > This may be a more javascript related topic, but it's also php/mysql.
> > > Apologies in advance if this is too far off topic.
> > >
> > > I'm trying to pull data from MySQL using PHP to sort the results into a
> > > form with a pull down menu. That works fine; I can do that.
> > >
> > > But I have a second pull down menu whose items need to display based on
> > > the item chosen from the first pull down menu.
> > >
> > > I can do two lists seperately, but I need the second pull down menu to be
> > > a result of the first, and I can't figure a way to do it in PHP without
> > > reloading the page, which I don't really want to do.
> > >
> > > Is this a javascript-dependent function, in that a js will have to make
> > > the call to the database via some sort of scripted php/mysql request? I
> > > really like to avoid javascript if possible, but I'm unsure there's an
> > > alternative.
> >
> > You're describing what I think is called "Dynamic Options". Doing a Google
> > for "javascript dynamic option" or "javascript dynamic select" will
> > pull-up
> > a few examples.
> >
> > Most of these solutions will expect you to load all data into javascript
> > arrays. In other words, you don't have to reload the page, because all of
> > the data is already present.
> >
> > This approach doesn't work well when dealing with large amounts of data. If
> > you're running into this, use javascript's window.opener feature. It allows
> > you to spawn a second window that retrieves data and sends it to the first
> > window.
Cripes! People are a bit slow today... what you are describing sounds
like a hierselect to me:
In pear,...
http://pear.php.net/package/HTML_QuickForm/docs/3.2.1/HTML_QuickForm/_HTML_QuickForm-3.2.1_QuickForm_hierselect_php.html
If you want to do it yourself just look at their code and get your
inspiration from there - and yes, their solution is javascript based.
Cheers
Antoine
--
G System, The Evolving GUniverse - http://www.g-system.at