how to automatically display from a list box?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2005
cricketunes@yahoo.com
 
Posts: n/a
Default how to automatically display from a list box?

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.

Reply With Quote
  #2 (permalink)  
Old 04-17-2005
Goran Ljubej
 
Posts: n/a
Default Re: how to automatically display from a list box?

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....
Reply With Quote
  #3 (permalink)  
Old 04-17-2005
cricketunes@yahoo.com
 
Posts: n/a
Default Re: how to automatically display from a list box?

But how does Javascript connect to the database and pull out the
corresponding values into the listbox?? can u pass PHP info to
Javascript?

Reply With Quote
  #4 (permalink)  
Old 04-17-2005
Micha³ Wo¼niak
 
Posts: n/a
Default Re: how to automatically display from a list box?

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
Reply With Quote
  #5 (permalink)  
Old 04-17-2005
Geoff Berrow
 
Posts: n/a
Default Re: how to automatically display from a list box?

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/
Reply With Quote
  #6 (permalink)  
Old 04-17-2005
cricketunes@yahoo.com
 
Posts: n/a
Default Re: how to automatically display from a list box?


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?

Reply With Quote
  #7 (permalink)  
Old 04-17-2005
Geoff Berrow
 
Posts: n/a
Default Re: how to automatically display from a list box?

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/
Reply With Quote
  #8 (permalink)  
Old 04-17-2005
jerry gitomer
 
Posts: n/a
Default Re: how to automatically display from a list box?

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>
";

Reply With Quote
  #9 (permalink)  
Old 04-21-2005
cricketunes@yahoo.com
 
Posts: n/a
Default Re: how to automatically display from a list box?

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.

Reply With Quote
  #10 (permalink)  
Old 04-21-2005
Geoff Berrow
 
Posts: n/a
Default Re: how to automatically display from a list box?

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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:22 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0