I’ve seen people asking how to do an “onpageload” with php and there isn’t a direct way like what jscript has:
[php]onload=“MyJScriptFunction();”[/php]
however, my example uses a checkbox and here’s how you can do it:
[php]
if(isset($_POST[“submit”])) // Button submit won’t be set on the first load of the page
{
if(isset($_POST[“checkbox”])) // since submit is set lets check to see if they selected a checkbox
{
$checkbox = “Y”; // the checkbox is checked
}
else
{
$checkbox = “”; // nothing checked so set to nothing
}
}
else // since submit wasn’t set let’s use a cookie or stored value when entering the page
{
$checkbox = $sess->checkbox; // You can use a cookie value here or some sort of default value;
}
// save the state of the checkbox
$sess->SetSessionVariable(“checkbox”, $checkbox);
[/php]
I had a need where I had to store the checkbox state when the client navigated off the site and came back. This works for that as well as radio buttons and defaulting variables.