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

Home » Imported messages » comp.lang.php » checkbox and reload a page
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
checkbox and reload a page [message #170851] Fri, 03 December 2010 11:36 Go to next message
anver is currently offline  anver
Messages: 5
Registered: November 2010
Karma: 0
Junior Member
a page with a checkbox and code:
in short

function A () {
checkbox (default off)
check off if {.. code ..)
}

problem:
when the page is loaded, is applied the ..code..;
I would like to click on the check and not apply the ..code..;
so is necessary to reload the page and maintain the value of the check
selected (notice this is a form similar at a form for to create own
account, so the state of checkbox cannot achivied in way permanent in the
db or in a php's variable, but used on the fly)


same code but using a variable

var_A = true;
function A () {
checkbox
if var_A {.. code ..)
}




------
more info



is similar to a normal registration user form with this difference:

generally in these forms, user active checkbox and after with send's button
the php passing its datas to another page;
in my case instead, the whole page is already pre-loaded and the same datas
aree send at a report's page for print;
so checkbox is used for reloading the same page but removing something
variables (with ..code.. that is an unset command)

(this isn't correct but is an attempt to change resuolts without having to
change the original code)


so the variable var_A, should be seen and used only locally,
because each user will opt for their choice


I think that php variable var_A should be relative only at that user while
use the form (cookies, sessions or others)
or integrated with a variable Javascript


how is possible to resolve?
Re: checkbox and reload a page [message #170854 is a reply to message #170851] Fri, 03 December 2010 14:56 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Dec 3, 11:36 am, anver <NOSP...@NO.SPAMMS> wrote:
> a page with a checkbox and code:
> in short
>
> function A () {
>     checkbox (default off)
>     check off if {.. code ..)
>
> }
>
> problem:
> when the page is loaded, is applied the ..code..;
> I would like to click on the check and not apply the ..code..;
Well you are in luck then. The box gets clicked on the browser and php
has no idea what is going on at the browser. You can click on the box
to your hearts content. No php code will get executed until the form
is submitted.
Re: checkbox and reload a page [message #170855 is a reply to message #170851] Fri, 03 December 2010 17:43 Go to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
anver wrote:

> is similar to a normal registration user form with this difference:
>
> generally in these forms, user active checkbox and after with send's button
> the php passing its datas to another page;
> in my case instead, the whole page is already pre-loaded and the same datas
> aree send at a report's page for print;
> so checkbox is used for reloading the same page but removing something
> variables (with ..code.. that is an unset command)

What you are looking for is really ajax, this is mainly done in javascript,
the script that receives the data or sends the data can of course be simple
php scripts.

1. you load a page with ajax.
2. action on the page executes the ajax function (to send or fetch data)
3. the php script will process the request and send a result back to the page
4. the ajax function will process the reply and displaying the result.

if you reload the page, it can be possible to have all the previous data
there, check boxes checked and so on, if the changes are always sent back and
stored in a session or stored in a normal cookie (the later can be done
without really using ajax).

For the javascript part, you have to seek out other places to discuss that,
when it comes to the php part, it's exactly the same as it would have been
with a standard form.

--

//Aho
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Evaluating an expression
Next Topic: comp.lang.php
Goto Forum:
  

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

Current Time: Tue Nov 26 11:01:02 GMT 2024

Total time taken to generate the page: 0.03596 seconds