Double drop down combo box
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
<select> however how is the data passed back into the combo, or is
there another way?
<td colspan="2"><select name="class" id="class"
onChange="SelectSubCat();">
<?php
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 "<option value=".$row['class'].">".$row['class']."</option>";
}
?>
</select></td>
RE: Double drop down combo box
Off-Topic nag by Jerry Stuckle in
10
9
8
7
6
Re: Double drop down combo box
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
> <select> however how is the data passed back into the combo, or is
> there another way?
>
> <td colspan="2"><select name="class" id="class"
> onChange="SelectSubCat();">
> <?php
> 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 "<option value=".$row['class'].">".$row['class']."</option>";
> }
> ?>
> </select></td>
>
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 [at] attglobal.net
==================
Re: Double drop down combo box
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
> <select> however how is the data passed back into the combo, or is
> there another way?
>
> <td colspan="2"><select name="class" id="class"
> onChange="SelectSubCat();">
> <?php
> 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 "<option value=".$row['class'].">".$row['class']."</option>";
> }
> ?>
> </select></td>
Re: Double drop down combo box
On Apr 9, 10:46=A0pm, The Natural Philosopher <a... [at] b.c> 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
>
>
>
> > <select> however how is the data passed back into the combo, or is
> > there another way?
>
> > <td colspan=3D"2"><select name=3D"class" id=3D"class"
> > onChange=3D"SelectSubCat();">
> > <?php
> > =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 "<option value=3D".$row['class'].">".$row['class']."</option=
>";
> > =A0 =A0}
> > ?>
> > </select></td>- Hide quoted text -
>
> - Show quoted text -
Groupie - please read this page :-
http://www.trans4mind.com/personal_development/JavaScript/Do ublemenu.htm
Rob,
Re: Double drop down combo box
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
> <select> however how is the data passed back into the combo, or is
> there another way?
>
> <td colspan="2"><select name="class" id="class"
> onChange="SelectSubCat();">
> <?php
> 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 "<option value=".$row['class'].">".$row['class']."</option>";
> }
> ?>
> </select></td>
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/