This is a discussion on how to automatically display from a list box? within the PHP Language forums, part of the PHP Programming Forums category; Hi Folks, I am working on a PHP/HTML form which supports End User queries. I need the user to ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi Folks,
I am working on a PHP/HTML form which supports End User queries. I need the user to select a combination of Airline and corresponding place of Origin. i,e Delta - Madison, Dallas, Atlanta KLM - Amsterdam, Houston, Detroit Brit - New York, London, Seattle I have a list of Airlines in a list box. The moment the user selects an Airline(Delta) from the List box, the list box below it needs to have (Dallas, Atlanta, Madison) as its options. How is this done? How do I use a listbox selection as a trigger an automatically start the next activity? Thanks Newbie to webdesign. |
|
|||
|
cricketunes@yahoo.com wrote:
> Hi Folks, > I am working on a PHP/HTML form which supports End User queries. > > I need the user to select a combination of Airline and corresponding > place of Origin. i,e > Delta - Madison, Dallas, Atlanta > KLM - Amsterdam, Houston, Detroit > Brit - New York, London, Seattle > > I have a list of Airlines in a list box. The moment the user selects an > Airline(Delta) from the List box, the list box below it needs to have > (Dallas, Atlanta, Madison) as its options. > > How is this done? How do I use a listbox selection as a trigger an > automatically start the next activity? > > Thanks > Newbie to webdesign. > in my opinion the only way to do this without refreshing is using javascript funcion.... |
|
|||
|
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable cricketunes@yahoo.com's handwriting: > But how does Javascript connect to the database and pull out the > corresponding values into the listbox?? can u pass PHP info to > Javascript? <SCRIPT language='javascript'> myJavaScriptVar=<?php echo $my_php_var ?>; </SCRIPT> And there you have it = your PHP variable gets "assigned" to javascript's variable. :) Cheers Mike |
|
|||
|
I noticed that Message-ID:
<1113710549.478602.217310@g14g2000cwa.googlegroups .com> from cricketunes@yahoo.com contained the following: >But how does Javascript connect to the database and pull out the >corresponding values into the listbox?? can u pass PHP info to >Javascript? You've seen how is done. The idea is to load up all the information into Javascript variables at the beginning. From then on everything is done client side. But you'll need to think of an alternative method for people who don't have Javascript enabled -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
Geoff Berrow wrote: > I noticed that Message-ID: > <1113710549.478602.217310@g14g2000cwa.googlegroups .com> from > cricketunes@yahoo.com contained the following: > > >But how does Javascript connect to the database and pull out the > >corresponding values into the listbox?? can u pass PHP info to > >Javascript? > > You've seen how is done. The idea is to load up all the information > into Javascript variables at the beginning. From then on everything is > done client side. Thanks Geoff and Mike :-) Can i Interject my PHP code with javascript blocks? |
|
|||
|
I noticed that Message-ID:
<1113726305.029183.54170@z14g2000cwz.googlegroups. com> from cricketunes@yahoo.com contained the following: >Can i Interject my PHP code with javascript blocks? You send Javascript just like you'd send HTML. Both are dealt with by the browser. But I'll repeat. You /must/ have an alternative method and I can see that you may be heading for a solution which relies on Javascript. You can't rely on Javascript being available. -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
cricketunes@yahoo.com wrote:
> Hi Folks, > I am working on a PHP/HTML form which supports End User queries. > > I need the user to select a combination of Airline and corresponding > place of Origin. i,e > Delta - Madison, Dallas, Atlanta > KLM - Amsterdam, Houston, Detroit > Brit - New York, London, Seattle > > I have a list of Airlines in a list box. The moment the user selects an > Airline(Delta) from the List box, the list box below it needs to have > (Dallas, Atlanta, Madison) as its options. > > How is this done? How do I use a listbox selection as a trigger an > automatically start the next activity? > > Thanks > Newbie to webdesign. > You can either use a drop down along with a submit button or build a one column (or more) HTML table and by using an HREF and making a table column "live" you can capture the airline information when your user clicks on an airline name. You can then use PHP to determine which airline was selected and present the user with a table containing that airline's schedule information. In the example below the list of properties is read from the database and each value displayed in a single column HTML table. When the user makes a select the php program doaup.php is invoked and the property name passed to it. (Note that this code will not run as is since I have cut out segments not related to illustrating my point.) $sql1 = "SELECT propname FROM gOProps WHERE accesscode = '$ac' ORDER BY propname"; $result1 = $db->query($sql1); echo "</table> <br><tr><th><p>Name</p></th></tr>"); while ($row = $result1->fetchRow()) { $propname = $row[0]; echo ("<tr><td> <a href='doaup.php?row_ID=$propname'> $propname</a></td></tr>"); } echo "</table> <br> "; |
|
|||
|
Thanks everyone. I am now using javascript functions for listbox
selection. however a couple of issues: My objective is to send the Form Variables within a PHP Script to the action-PHP file. So in this case: Wouldn't my requirement be embedding javascript within PHP and not the other way round? Or is it to have PHP within javascript? Will the Action-PHP file still receive Form data when PHP is within javascript? Thanks. |
|
|||
|
I noticed that Message-ID:
<1114043254.511338.179710@o13g2000cwo.googlegroups .com> from cricketunes@yahoo.com contained the following: >My objective is to send the Form Variables within a PHP Script to the >action-PHP file. So in this case: >Wouldn't my requirement be embedding javascript within PHP and not the >other way round? >Or is it to have PHP within javascript? Will the Action-PHP file still >receive Form data when PHP is within javascript? PHP runs on the server. Javascript runs on the client. Please try to get your head around this. There is no interaction. PHP can output Javascript, but as far as PHP is concerned it is just text. -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |