|
Posted by OmegaJunior on 12/26/06 01:32
On Tue, 26 Dec 2006 00:47:55 +0100, Charles O'Flynn <carles@matchwalk.co=
m> =
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 o=
f
> thing, and this is the best I can come up with. For reference, the pa=
ge =
> is
> at http://dev.matchwalk.com - click on 'Weather forecast' under 'Relat=
ed
> 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 dropdow=
n =
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 t=
he =
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 re=
ad =
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'])=3D=3Dtrue)), show a default location of your=
=
choosing.
Hope this helps!
-- =
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
[Back to original message]
|