You are here: Re: Forms « All PHP « IT news, forums, messages
Re: Forms

Posted by Charles O'Flynn on 12/26/06 13:53

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/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация