FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » button, parameter and reload - How do I glue it all together?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: button, parameter and reload - How do I glue it all together? [message #178786 is a reply to message #178785] Fri, 03 August 2012 15:23 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
mwoolley wrote:
> I have a webpage, on which the content displayed depends on a parameter passed to or obtained by the webpage. This might be a $_GET variable, a $_SESSION variable or a cookie. I don't mind which is used. (I am open to suggestions as to which is the best method. I think $_SESSION.) When the page is initially displayed, the parameter is unset.
>
> On said page, there is to be a button, which when clicked, will increment the parameter and reload the page. Obviously, the parameter has to have the new value, so the reload causes the page contents to change. This ooperation might be repeated ad-nausem.
>
> Most of the indivual pieces of this (getting the paramter, and having the button reload the page) I can do, but I'm having trouble glueing it all together. I've managed to increment the parameter when the button is pressed, but only by calling an external form tag handler. If I do this, I can't get the page to reload.
>
> By what mechanism, can I have the button increment the parameter and cause the page reload?
>
By making the button perform a submit action - either becuse its a
submit button, or its a url button that calls the page with a parameter
set as a GET or because its hooked to javsacript that causes a submit
and sets parameters on the way.

In general your PHP code should be of the form

IF
(page is to be displayed as a result of a submit action )
THEN
(update any persistent data like a database with the users
entry data contained in the POST variables)

(get the parameters and make up the display according
to what they are )
ELSE
(display an initial page reflecting no user input yet)


($SESSION is a use of cookies by the way. Its just cookies wrapped in a
simple API.)


The only way you can do this without a submit action is to downland ALL
the possible screen options in e.g. a javascript array and display the
selection you want depending on buttons hooked to javascript functions.

You would typically do that if you wanted to give the user something
like an online calculator or some similar app.

Whereas posting data and reloading the page is more appropriate as a
forms front end to a database for example.

You can mix the two, but it gets complicated. I have done that to create
huge menu systems reflecting a hierarchy of parts in a stock database.
ALL the parts are downloaded and they are only revealed when the user
navigates a selection of drop down menus.




> I hope this make sense; the old grey matter is addled today!
>
> Thanks in advance.
> Martin


--
To people who know nothing, anything is possible.
To people who know too much, it is a sad fact
that they know how little is really possible -
and how hard it is to achieve it.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: App2Fame is back: Bigger, Better & Loads of Prizes.
Next Topic: Handling with xmlhttp.responseText
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 01 12:45:58 GMT 2024

Total time taken to generate the page: 0.04303 seconds