Bluehost.com Web Hosting $6.95

Forms

This is a discussion on Forms within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Can anyone help, please? I am writing a program that has a drop-down list to allow the user to ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-26-2006
Charles O'Flynn
 
Posts: n/a
Default Forms

Can anyone help, please?
I am writing a program that has a drop-down list to allow the user to change
one of the variables. The drop-down is coded in HTML. I know how to
refresh the screen in HTML but not in PHP.
The idea is to re-draw the screen with one of the variables re-defined,
thereby producing a completely different display. Possibly my fundamental
approach is wrong, but I'm not particularly experienced in this sort of
thing, and this is the best I can come up with. For reference, the page is
at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
links'. I want to be able to alter the location to which the forecast
refers.
Thanks in advance for any suggestions.
Charles


Reply With Quote
  #2 (permalink)  
Old 12-26-2006
OmegaJunior
 
Posts: n/a
Default Re: Forms

On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn <carles@matchwalk.com>
wrote:

> Can anyone help, please?
> I am writing a program that has a drop-down list to allow the user to
> change
> one of the variables. The drop-down is coded in HTML. I know how to
> refresh the screen in HTML but not in PHP.
> The idea is to re-draw the screen with one of the variables re-defined,
> thereby producing a completely different display. Possibly my
> fundamental
> approach is wrong, but I'm not particularly experienced in this sort of
> thing, and this is the best I can come up with. For reference, the page
> is
> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
> links'. I want to be able to alter the location to which the forecast
> refers.
> Thanks in advance for any suggestions.
> Charles
>
>


If you already know HTML form submitting techniques, this should be
relatively easy to understand.

In your current setup, you have a form named "weatherForm" with a "get"
method, but without an action attribute. Instead, you use a javascripted
"updatelocation" method that reacts to the onSelect event of the dropdown
list.

There is a set of methods named "AJAX" that allows you to load new
information dynamically, based on javascript methods. Though this is a
very nice way of handling it, it's also extremely cumbersome compared to
the "old school" technique of simply submitting the form.

How to do it:
Add a submit input to your form and title it aptly, like "Go". Add an
action attribute to your form, and as its value you assign the name of the
current script. So basically you're submitting the form to its own page.

Then in the current script, before building the rest of the page, you read
the querystring using the variable $_GET['location'] (PHP 4 and up will
create this variable for you automatically because the form was
submitted). Upon knowing the location, you choose the correct data to
present. If that variable isn't filled in (check with
if(isset($_GET['location'])==true)), show a default location of your
choosing.

Hope this helps!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Reply With Quote
  #3 (permalink)  
Old 12-26-2006
Charles O'Flynn
 
Posts: n/a
Default Re: Forms

Thank you very much for this - the HTML bit I was reasonably aware of but
I'm not sufficiently familiar with PHP to have been able to work that
without some help.
I'll try it out tomorrow when I get back to my PC.
Just out of interest, the AJAX method sounds as though it is what I
originally had in mind. Where can I get more information on it? It would
have been nice to have the location change without having to press a submit
button.
Thanks again!
Charles



"OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
news:op.tk47vvww70mclq@cp139795-a.landg1.lb.home.nl...
On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn <carles@matchwalk.com>
wrote:

> Can anyone help, please?
> I am writing a program that has a drop-down list to allow the user to
> change
> one of the variables. The drop-down is coded in HTML. I know how to
> refresh the screen in HTML but not in PHP.
> The idea is to re-draw the screen with one of the variables re-defined,
> thereby producing a completely different display. Possibly my
> fundamental
> approach is wrong, but I'm not particularly experienced in this sort of
> thing, and this is the best I can come up with. For reference, the page
> is
> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
> links'. I want to be able to alter the location to which the forecast
> refers.
> Thanks in advance for any suggestions.
> Charles
>
>


If you already know HTML form submitting techniques, this should be
relatively easy to understand.

In your current setup, you have a form named "weatherForm" with a "get"
method, but without an action attribute. Instead, you use a javascripted
"updatelocation" method that reacts to the onSelect event of the dropdown
list.

There is a set of methods named "AJAX" that allows you to load new
information dynamically, based on javascript methods. Though this is a
very nice way of handling it, it's also extremely cumbersome compared to
the "old school" technique of simply submitting the form.

How to do it:
Add a submit input to your form and title it aptly, like "Go". Add an
action attribute to your form, and as its value you assign the name of the
current script. So basically you're submitting the form to its own page.

Then in the current script, before building the rest of the page, you read
the querystring using the variable $_GET['location'] (PHP 4 and up will
create this variable for you automatically because the form was
submitted). Upon knowing the location, you choose the correct data to
present. If that variable isn't filled in (check with
if(isset($_GET['location'])==true)), show a default location of your
choosing.

Hope this helps!

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


Reply With Quote
  #4 (permalink)  
Old 12-27-2006
OmegaJunior
 
Posts: n/a
Default Re: Forms

Welcome!

For AJAX you can hit Google. It's the new hype today, as people believe
they invented the wheel.

Cheers!

On Tue, 26 Dec 2006 14:53:46 +0100, Charles O'Flynn <carles@matchwalk.com>
wrote:

> Thank you very much for this - the HTML bit I was reasonably aware of but
> I'm not sufficiently familiar with PHP to have been able to work that
> without some help.
> I'll try it out tomorrow when I get back to my PC.
> Just out of interest, the AJAX method sounds as though it is what I
> originally had in mind. Where can I get more information on it? It
> would
> have been nice to have the location change without having to press a
> submit
> button.
> Thanks again!
> Charles
>
>
>
> "OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
> news:op.tk47vvww70mclq@cp139795-a.landg1.lb.home.nl...
> On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn
> <carles@matchwalk.com>
> wrote:
>
>> Can anyone help, please?
>> I am writing a program that has a drop-down list to allow the user to
>> change
>> one of the variables. The drop-down is coded in HTML. I know how to
>> refresh the screen in HTML but not in PHP.
>> The idea is to re-draw the screen with one of the variables re-defined,
>> thereby producing a completely different display. Possibly my
>> fundamental
>> approach is wrong, but I'm not particularly experienced in this sort of
>> thing, and this is the best I can come up with. For reference, the page
>> is
>> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
>> links'. I want to be able to alter the location to which the forecast
>> refers.
>> Thanks in advance for any suggestions.
>> Charles
>>
>>

>
> If you already know HTML form submitting techniques, this should be
> relatively easy to understand.
>
> In your current setup, you have a form named "weatherForm" with a "get"
> method, but without an action attribute. Instead, you use a javascripted
> "updatelocation" method that reacts to the onSelect event of the dropdown
> list.
>
> There is a set of methods named "AJAX" that allows you to load new
> information dynamically, based on javascript methods. Though this is a
> very nice way of handling it, it's also extremely cumbersome compared to
> the "old school" technique of simply submitting the form.
>
> How to do it:
> Add a submit input to your form and title it aptly, like "Go". Add an
> action attribute to your form, and as its value you assign the name of
> the
> current script. So basically you're submitting the form to its own page.
>
> Then in the current script, before building the rest of the page, you
> read
> the querystring using the variable $_GET['location'] (PHP 4 and up will
> create this variable for you automatically because the form was
> submitted). Upon knowing the location, you choose the correct data to
> present. If that variable isn't filled in (check with
> if(isset($_GET['location'])==true)), show a default location of your
> choosing.
>
> Hope this helps!
>




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Reply With Quote
  #5 (permalink)  
Old 12-28-2006
Serge Terryn
 
Posts: n/a
Default Re: Forms

Charles O'Flynn schreef:
> Thank you very much for this - the HTML bit I was reasonably aware of but
> I'm not sufficiently familiar with PHP to have been able to work that
> without some help.
> I'll try it out tomorrow when I get back to my PC.
> Just out of interest, the AJAX method sounds as though it is what I
> originally had in mind. Where can I get more information on it? It would
> have been nice to have the location change without having to press a submit
> button.
> Thanks again!
> Charles
>
>
>
> "OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
> news:op.tk47vvww70mclq@cp139795-a.landg1.lb.home.nl...
> On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn <carles@matchwalk.com>
> wrote:
>
>> Can anyone help, please?
>> I am writing a program that has a drop-down list to allow the user to
>> change
>> one of the variables. The drop-down is coded in HTML. I know how to
>> refresh the screen in HTML but not in PHP.
>> The idea is to re-draw the screen with one of the variables re-defined,
>> thereby producing a completely different display. Possibly my
>> fundamental
>> approach is wrong, but I'm not particularly experienced in this sort of
>> thing, and this is the best I can come up with. For reference, the page
>> is
>> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
>> links'. I want to be able to alter the location to which the forecast
>> refers.
>> Thanks in advance for any suggestions.
>> Charles
>>
>>

>
> If you already know HTML form submitting techniques, this should be
> relatively easy to understand.
>
> In your current setup, you have a form named "weatherForm" with a "get"
> method, but without an action attribute. Instead, you use a javascripted
> "updatelocation" method that reacts to the onSelect event of the dropdown
> list.
>
> There is a set of methods named "AJAX" that allows you to load new
> information dynamically, based on javascript methods. Though this is a
> very nice way of handling it, it's also extremely cumbersome compared to
> the "old school" technique of simply submitting the form.
>
> How to do it:
> Add a submit input to your form and title it aptly, like "Go". Add an
> action attribute to your form, and as its value you assign the name of the
> current script. So basically you're submitting the form to its own page.
>
> Then in the current script, before building the rest of the page, you read
> the querystring using the variable $_GET['location'] (PHP 4 and up will
> create this variable for you automatically because the form was
> submitted). Upon knowing the location, you choose the correct data to
> present. If that variable isn't filled in (check with
> if(isset($_GET['location'])==true)), show a default location of your
> choosing.
>
> Hope this helps!
>


To refresh a page without a submit button, you need javascript.

<form action="script" method="post">
<input type="text" name="zoek" value="Zoeken">
<input type="submit" value="OK" class="button">
</form>

onfocus="if(this.value=='Zoeken') this.value='';"

<form action="script" method="post">
<input type="text" name="zoek" value="Zoeken" onfocus="if
(this.value=='Zoeken')
this.value='';">
<input type="submit" value="OK" class="button">
</form>

onblur="if(this.value=='') this.value='Zoeken';"

<form action="script" method="post">
<input type="text" name="zoek" value="Zoeken" onfocus="if
(this.value=='Zoeken')
this.value='';" onblur="if(this.value=='')
this.value='Zoeken';">
<input type="submit" value="OK" class="button">
</form>


--
Posting at the top because that's where the cursor happened to be,
is like shitting in your pants because that's where your asshole
happened to be.

http://www.essetee.be
Reply With Quote
  #6 (permalink)  
Old 12-28-2006
Charles O'Flynn
 
Posts: n/a
Default Re: Forms

It's now working - results at http://www.matchwalk.com (Weather page). Once
I knew where to start looking for reference material, it was easy.
Very many thanks again.
charles



"OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
news:op.tk73tslo70mclq@cp139795-a.landg1.lb.home.nl...
Welcome!

For AJAX you can hit Google. It's the new hype today, as people believe
they invented the wheel.

Cheers!

On Tue, 26 Dec 2006 14:53:46 +0100, Charles O'Flynn <charles@matchwalk.com>
wrote:

> Thank you very much for this - the HTML bit I was reasonably aware of but
> I'm not sufficiently familiar with PHP to have been able to work that
> without some help.
> I'll try it out tomorrow when I get back to my PC.
> Just out of interest, the AJAX method sounds as though it is what I
> originally had in mind. Where can I get more information on it? It
> would
> have been nice to have the location change without having to press a
> submit
> button.
> Thanks again!
> Charles
>
>
>
> "OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
> news:op.tk47vvww70mclq@cp139795-a.landg1.lb.home.nl...
> On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn
> <charles@matchwalk.com>
> wrote:
>
>> Can anyone help, please?
>> I am writing a program that has a drop-down list to allow the user to
>> change
>> one of the variables. The drop-down is coded in HTML. I know how to
>> refresh the screen in HTML but not in PHP.
>> The idea is to re-draw the screen with one of the variables re-defined,
>> thereby producing a completely different display. Possibly my
>> fundamental
>> approach is wrong, but I'm not particularly experienced in this sort of
>> thing, and this is the best I can come up with. For reference, the page
>> is
>> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
>> links'. I want to be able to alter the location to which the forecast
>> refers.
>> Thanks in advance for any suggestions.
>> Charles
>>
>>

>
> If you already know HTML form submitting techniques, this should be
> relatively easy to understand.
>
> In your current setup, you have a form named "weatherForm" with a "get"
> method, but without an action attribute. Instead, you use a javascripted
> "updatelocation" method that reacts to the onSelect event of the dropdown
> list.
>
> There is a set of methods named "AJAX" that allows you to load new
> information dynamically, based on javascript methods. Though this is a
> very nice way of handling it, it's also extremely cumbersome compared to
> the "old school" technique of simply submitting the form.
>
> How to do it:
> Add a submit input to your form and title it aptly, like "Go". Add an
> action attribute to your form, and as its value you assign the name of
> the
> current script. So basically you're submitting the form to its own page.
>
> Then in the current script, before building the rest of the page, you
> read
> the querystring using the variable $_GET['location'] (PHP 4 and up will
> create this variable for you automatically because the form was
> submitted). Upon knowing the location, you choose the correct data to
> present. If that variable isn't filled in (check with
> if(isset($_GET['location'])==true)), show a default location of your
> choosing.
>
> Hope this helps!
>




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


Reply With Quote
  #7 (permalink)  
Old 12-28-2006
Charles O'Flynn
 
Posts: n/a
Default Re: Forms

"Serge Terryn" <serge@essetee.be> wrote in message
news:2LDkh.259886$8z5.5548174@phobos.telenet-ops.be...
> Charles O'Flynn schreef:
>> Thank you very much for this - the HTML bit I was reasonably aware of but
>> I'm not sufficiently familiar with PHP to have been able to work that
>> without some help.
>> I'll try it out tomorrow when I get back to my PC.
>> Just out of interest, the AJAX method sounds as though it is what I
>> originally had in mind. Where can I get more information on it? It
>> would have been nice to have the location change without having to press
>> a submit button.
>> Thanks again!
>> Charles
>>
>>
>>
>> "OmegaJunior" <omegajunior@spamremove.home.nl> wrote in message
>> news:op.tk47vvww70mclq@cp139795-a.landg1.lb.home.nl...
>> On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn
>> <carles@matchwalk.com>
>> wrote:
>>
>>> Can anyone help, please?
>>> I am writing a program that has a drop-down list to allow the user to
>>> change
>>> one of the variables. The drop-down is coded in HTML. I know how to
>>> refresh the screen in HTML but not in PHP.
>>> The idea is to re-draw the screen with one of the variables re-defined,
>>> thereby producing a completely different display. Possibly my
>>> fundamental
>>> approach is wrong, but I'm not particularly experienced in this sort of
>>> thing, and this is the best I can come up with. For reference, the page
>>> is
>>> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Related
>>> links'. I want to be able to alter the location to which the forecast
>>> refers.
>>> Thanks in advance for any suggestions.
>>> Charles
>>>
>>>

>>
>> If you already know HTML form submitting techniques, this should be
>> relatively easy to understand.
>>
>> In your current setup, you have a form named "weatherForm" with a "get"
>> method, but without an action attribute. Instead, you use a javascripted
>> "updatelocation" method that reacts to the onSelect event of the dropdown
>> list.
>>
>> There is a set of methods named "AJAX" that allows you to load new
>> information dynamically, based on javascript methods. Though this is a
>> very nice way of handling it, it's also extremely cumbersome compared to
>> the "old school" technique of simply submitting the form.
>>
>> How to do it:
>> Add a submit input to your form and title it aptly, like "Go". Add an
>> action attribute to your form, and as its value you assign the name of
>> the
>> current script. So basically you're submitting the form to its own page.
>>
>> Then in the current script, before building the rest of the page, you
>> read
>> the querystring using the variable $_GET['location'] (PHP 4 and up will
>> create this variable for you automatically because the form was
>> submitted). Upon knowing the location, you choose the correct data to
>> present. If that variable isn't filled in (check with
>> if(isset($_GET['location'])==true)), show a default location of your
>> choosing.
>>
>> Hope this helps!
>>

>
> To refresh a page without a submit button, you need javascript.
>
> <form action="script" method="post">
> <input type="text" name="zoek" value="Zoeken">
> <input type="submit" value="OK" class="button">
> </form>
>
> onfocus="if(this.value=='Zoeken') this.value='';"
>
> <form action="script" method="post">
> <input type="text" name="zoek" value="Zoeken" onfocus="if
> (this.value=='Zoeken')
> this.value='';">
> <input type="submit" value="OK" class="button">
> </form>
>
> onblur="if(this.value=='') this.value='Zoeken';"
>
> <form action="script" method="post">
> <input type="text" name="zoek" value="Zoeken" onfocus="if
> (this.value=='Zoeken')
> this.value='';" onblur="if(this.value=='')
> this.value='Zoeken';">
> <input type="submit" value="OK" class="button">
> </form>
>
>
> --
> Posting at the top because that's where the cursor happened to be,
> is like shitting in your pants because that's where your asshole
> happened to be.


Perhaps so, but it's more logical than speaking and writing in American
when the home of the English language is almost on your doorstep.




Many thanks for the tip - I'll have a look at adapting my code to see if I
can make this work for my particular circumstances - I still need to be able
to pass info between pages without using cookies if possible, but this looks
like the sort of thing I was after.


Reply With Quote
  #8 (permalink)  
Old 12-28-2006
Serge Terryn
 
Posts: n/a
Default Re: Forms

Charles O'Flynn schreef:

>
> Many thanks for the tip - I'll have a look at adapting my code to see if I
> can make this work for my particular circumstances - I still need to be able
> to pass info between pages without using cookies if possible, but this looks
> like the sort of thing I was after.
>
>


For that purpose you have $_SESSION


--
Posting at the top because that's where the cursor happened to be,
is like shitting in your pants because that's where your asshole
happened to be.

http://www.essetee.be
Reply With Quote
  #9 (permalink)  
Old 12-29-2006
Charles O'Flynn
 
Posts: n/a
Default Re: Forms

"Serge Terryn" <serge@essetee.be> wrote in message
news:%8Lkh.260426$JD.5667974@phobos.telenet-ops.be...
> Charles O'Flynn schreef:
>
>>
>> Many thanks for the tip - I'll have a look at adapting my code to see if
>> I can make this work for my particular circumstances - I still need to be
>> able to pass info between pages without using cookies if possible, but
>> this looks like the sort of thing I was after.

>
> For that purpose you have $_SESSION
>

Thanks again - I thought that $_SESSION uses cookies when available but in
fact, this may be a fairly good idea, having thought about it a little bit
longer.
Dank U.
Charles


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 06:31 PM.


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