[PHP-DB] Drop-down menu selection

2001-02-20 Thread Julio Cuz, Jr.

Hi--

I hope all of you are having a great long weekend!

Let's say I have four (4) tables:

- "campus" that holds all my campuses' names (only 3),
- "building_campus1" that holds all buildings for 'campus1',
- "building_campus2" that holds all buildings for 'campus2',
- "building_campus3" that holds all buildings for 'campus3'.

If the user selects "campus 1" from a drop-menu, how can I select 
"buildings for campus 1" on a second drop-down menu?  In other words, how 
do I select the corresponding "building's table" when any "campus" is selected?

Thanks!

P.S.  I have tried the 'onChange' command, but I guess I got the syntax wrong:

=
// $campus:
?php
echo("SELECT onChange='building.value = building.this.value' NAME='campus'");
$cmlist = @pg_exec($db, "SELECT * FROM \"Campus\"") or 
die(include("../sqlerror.inc"));
$i = 0;
$x = pg_numrows($cmlist);
while ($i  $x):
 $clist = pg_fetch_array($cmlist,$i);
 echo "OPTION 
VALUE='".$clist["Campus"]."'".$clist["Campus"]."/OPTION";
 $i++;
endwhile;
echo("/SELECT");
?

$building:
?php
echo("SELECT NAME='building'");
$cmlist = @pg_exec($db, "SELECT * FROM building_$campus") or 
die(include("../sqlerror.inc"));
$i = 0;
$x = pg_numrows($cmlist);
while ($i  $x):
 $clist = pg_fetch_array($cmlist,$i);
 echo "OPTION 
VALUE='".$clist["Building"]."'".$clist["Building"]."/OPTION";
 $i++;
endwhile;
echo("/SELECT");
?
=

Julio Cuz, Jr.
Riverside Community College
[EMAIL PROTECTED] 


Re: [PHP-DB] Drop-down menu selection

2001-02-20 Thread JJeffman

You need mix JavaScript and PHP. Write an "OnChange" event handler for the
"campus" selection list and fill up the "buildings" drop-down menu in two
ways:

1) If the amount of data is not very large you can get all data needed to
run
the "application" client side, load the data into JavaScript arrays and
refresh the select boxes using JavaScript scripts. Otherwise you must reload
the page and process the values posted by the form.

2) Reload the same page (window.location="self.php?campus=value") and run
your php script to fill up the "buildings" drop-down menu.

HTH.

Jayme.


-Mensagem Original-
De: Julio Cuz, Jr. [EMAIL PROTECTED]
Para: [EMAIL PROTECTED]
Enviada em: tera-feira, 20 de fevereiro de 2001 21:44
Assunto: [PHP-DB] Drop-down menu selection


 Hi--

 I hope all of you are having a great long weekend!

 Let's say I have four (4) tables:

 - "campus" that holds all my campuses' names (only 3),
 - "building_campus1" that holds all buildings for 'campus1',
 - "building_campus2" that holds all buildings for 'campus2',
 - "building_campus3" that holds all buildings for 'campus3'.

 If the user selects "campus 1" from a drop-menu, how can I select
 "buildings for campus 1" on a second drop-down menu?  In other words, how
 do I select the corresponding "building's table" when any "campus" is
selected?

 Thanks!

 P.S.  I have tried the 'onChange' command, but I guess I got the syntax
wrong:

 =
 // $campus:
 ?php
 echo("SELECT onChange='building.value = building.this.value'
NAME='campus'");
 $cmlist = @pg_exec($db, "SELECT * FROM \"Campus\"") or
 die(include("../sqlerror.inc"));
 $i = 0;
 $x = pg_numrows($cmlist);
 while ($i  $x):
  $clist = pg_fetch_array($cmlist,$i);
  echo "OPTION
 VALUE='".$clist["Campus"]."'".$clist["Campus"]."/OPTION";
  $i++;
 endwhile;
 echo("/SELECT");
 ?

 $building:
 ?php
 echo("SELECT NAME='building'");
 $cmlist = @pg_exec($db, "SELECT * FROM building_$campus") or
 die(include("../sqlerror.inc"));
 $i = 0;
 $x = pg_numrows($cmlist);
 while ($i  $x):
  $clist = pg_fetch_array($cmlist,$i);
  echo "OPTION
 VALUE='".$clist["Building"]."'".$clist["Building"]."/OPTION";
  $i++;
 endwhile;
 echo("/SELECT");
 ?
 =

 Julio Cuz, Jr.
 Riverside Community College
 [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Drop-down menu selection

2001-02-20 Thread Thor M. Steindorsson

If he's reloading the same page, he doesn't even need javascript.
but to do this without reloading the page, he can have php populate a
javascript array, that can be used to re-populate the drop-down menu on the
fly.


-Original Message-
From: JJeffman [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 20, 2001 5:29 PM
To: [EMAIL PROTECTED]; Julio Cuz, Jr.
Subject: Re: [PHP-DB] Drop-down menu selection


You need mix JavaScript and PHP. Write an "OnChange" event handler for the
"campus" selection list and fill up the "buildings" drop-down menu in two
ways:

1) If the amount of data is not very large you can get all data needed to
run
the "application" client side, load the data into JavaScript arrays and
refresh the select boxes using JavaScript scripts. Otherwise you must reload
the page and process the values posted by the form.

2) Reload the same page (window.location="self.php?campus=value") and run
your php script to fill up the "buildings" drop-down menu.

HTH.

Jayme.


-Mensagem Original-
De: Julio Cuz, Jr. [EMAIL PROTECTED]
Para: [EMAIL PROTECTED]
Enviada em: tera-feira, 20 de fevereiro de 2001 21:44
Assunto: [PHP-DB] Drop-down menu selection


 Hi--

 I hope all of you are having a great long weekend!

 Let's say I have four (4) tables:

 - "campus" that holds all my campuses' names (only 3),
 - "building_campus1" that holds all buildings for 'campus1',
 - "building_campus2" that holds all buildings for 'campus2',
 - "building_campus3" that holds all buildings for 'campus3'.

 If the user selects "campus 1" from a drop-menu, how can I select
 "buildings for campus 1" on a second drop-down menu?  In other words, how
 do I select the corresponding "building's table" when any "campus" is
selected?

 Thanks!

 P.S.  I have tried the 'onChange' command, but I guess I got the syntax
wrong:

 =
 // $campus:
 ?php
 echo("SELECT onChange='building.value = building.this.value'
NAME='campus'");
 $cmlist = @pg_exec($db, "SELECT * FROM \"Campus\"") or
 die(include("../sqlerror.inc"));
 $i = 0;
 $x = pg_numrows($cmlist);
 while ($i  $x):
  $clist = pg_fetch_array($cmlist,$i);
  echo "OPTION
 VALUE='".$clist["Campus"]."'".$clist["Campus"]."/OPTION";
  $i++;
 endwhile;
 echo("/SELECT");
 ?

 $building:
 ?php
 echo("SELECT NAME='building'");
 $cmlist = @pg_exec($db, "SELECT * FROM building_$campus") or
 die(include("../sqlerror.inc"));
 $i = 0;
 $x = pg_numrows($cmlist);
 while ($i  $x):
  $clist = pg_fetch_array($cmlist,$i);
  echo "OPTION
 VALUE='".$clist["Building"]."'".$clist["Building"]."/OPTION";
  $i++;
 endwhile;
 echo("/SELECT");
 ?
 =

 Julio Cuz, Jr.
 Riverside Community College
 [EMAIL PROTECTED]


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]