|
Posted by Serge Terryn on 12/27/06 23:56
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
[Back to original message]
|