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

From: Date: Wed, 21 Feb 2001 03:03:43 +0000
Subject: RE: [PHP-DB] Drop-down menu selection
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6809@lists.php.net to get a copy of this message
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:jjeffmanweb@conex.com.br] Sent: Tuesday, February 20, 2001 5:29 PM To: php-db@lists.php.net; 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. <jcuz@rccd.cc.ca.us> Para: <php-db@lists.php.net> Enviada em: terça-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 > jcuz@rccd.cc.ca.us -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#6809) next »