checkbox and reload a page

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
a page with a checkbox and code:
in short

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

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 () {
    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

Quoted text here. Click to load it
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

anver wrote:

Quoted text here. Click to load it

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.



Site Timeline