Double drop down combo box

Double drop down combo box

am 09.04.2008 22:20:56 von groupie

Hi,
My code in the form below fills up the first combo box. How to fill up
a second related box, i.e. first box selected value determines the
second. I was thinking of the onChange="SelectSubCat();" event in
onChange="SelectSubCat();">
require("scripts/php/config.php");
$query = 'SELECT `tblclass`.`class`' . ' FROM tblclass' ;
$result=mysql_query($query) or die ("Unable to Make the Query:" .
mysql_error() );
while($row=mysql_fetch_array($result))
{
echo "";
}
?>

RE: Double drop down combo box

am 09.04.2008 23:33:55 von Off-Topic Police

Off-Topic nag by Jerry Stuckle in

10

9

8

7

6

Re: Double drop down combo box

am 09.04.2008 23:44:26 von Jerry Stuckle

groupie wrote:
> Hi,
> My code in the form below fills up the first combo box. How to fill up
> a second related box, i.e. first box selected value determines the
> second. I was thinking of the onChange="SelectSubCat();" event in
> > onChange="SelectSubCat();">
> > require("scripts/php/config.php");
> $query = 'SELECT `tblclass`.`class`' . ' FROM tblclass' ;
> $result=mysql_query($query) or die ("Unable to Make the Query:" .
> mysql_error() );
> while($row=mysql_fetch_array($result))
> {
> echo "";
> }
> ?>
>
>

You'll want something client-side to handle it; you can do it in PHP,
but you'll have to reload the entire page to get what you want. Even
then, to automate it you'll need javascript. So the easiest way will be
to use AJAX. Check out comp.lang.javascript for more info.

Alternatively, as a PHP solution, they need to submit the page; you look
at the value in the first box and resend the entire page with the
correct options for the second box.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Double drop down combo box

am 09.04.2008 23:46:29 von Courtney

groupie wrote:
> Hi,
> My code in the form below fills up the first combo box. How to fill up
> a second related box, i.e. first box selected value determines the
> second.

This can't be done serverside.

Its full javascript for this one.

Yoiu have to rewrite the contents of a bunch of select stuff on the
onchange() type mechanism.


I was thinking of the onChange="SelectSubCat();" event in
> > onChange="SelectSubCat();">
> > require("scripts/php/config.php");
> $query = 'SELECT `tblclass`.`class`' . ' FROM tblclass' ;
> $result=mysql_query($query) or die ("Unable to Make the Query:" .
> mysql_error() );
> while($row=mysql_fetch_array($result))
> {
> echo "";
> }
> ?>
>

Re: Double drop down combo box

am 10.04.2008 10:10:16 von Rob

On Apr 9, 10:46=A0pm, The Natural Philosopher wrote:
> groupie wrote:
> > Hi,
> > My code in the form below fills up the first combo box. How to fill up
> > a second related box, i.e. first box selected value determines the
> > second.
>
> This can't be done serverside.
>
> Its full javascript for this one.
>
> Yoiu have to rewrite the contents of a bunch of select stuff on the
> onchange() type mechanism.
>
> I was thinking of the onChange=3D"SelectSubCat();" event in
>
>
>
> > > > onChange=3D"SelectSubCat();">
> > > > =A0 =A0require("scripts/php/config.php");
> > =A0 =A0$query =3D 'SELECT `tblclass`.`class`' . ' FROM tblclass' ;
> > =A0 =A0$result=3Dmysql_query($query) or die ("Unable to Make the Query:"=
.
> > mysql_error() );
> > =A0 =A0while($row=3Dmysql_fetch_array($result))
> > =A0 =A0{
> > =A0 =A0echo "

Re: Double drop down combo box

am 11.04.2008 04:42:50 von Manuel Lemos

Hello,

on 04/09/2008 05:20 PM groupie said the following:
> Hi,
> My code in the form below fills up the first combo box. How to fill up
> a second related box, i.e. first box selected value determines the
> second. I was thinking of the onChange="SelectSubCat();" event in
> > onChange="SelectSubCat();">
> > require("scripts/php/config.php");
> $query = 'SELECT `tblclass`.`class`' . ' FROM tblclass' ;
> $result=mysql_query($query) or die ("Unable to Make the Query:" .
> mysql_error() );
> while($row=mysql_fetch_array($result))
> {
> echo "";
> }
> ?>
>

This is a recurring subject. If you searched the archives you could find
the answer.

I am going to paste my previous reply to the last person that asked the
same:

This forms generation class comes with a plug-in that does exactly that.

http://www.phpclasses.org/formsgeneration

It requires some Javascript to send AJAX request to the server, so the
plug-in itself queries the database and sends the select input options o
the browser. But you do not have to worry because the class generates
all the necessary Javascript for you.

Here is a live example of the plug-in:

http://www.meta-language.net/forms-examples.html?example=tes t_linked_select

You may also want to watch this tutorial video:

http://www.phpclasses.org/browse/video/1/package/1/section/p lugin-linked-select.html


--

Regards,
Manuel Lemos

PHP professionals looking for PHP jobs
http://www.phpclasses.org/professionals/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/