Jump to content

[SOLVED] Help with php in onclick


sheen4him

Recommended Posts

I am trying to change some variables based on a click of a checkbox. The code is attached. It seems to run the code even on page load. As you can see I set $_SESSION['intspouse'] back to 0, but it is always 1 or 2 when i reload the page. Please help. If you have a better way in PHP that would be fine also. I need to do this in many pages, so the easier the better. Thanks!

// near top of page
include(_INC_DIR."loadform.php");
$startspouse = $Spouse;
$formno=$Occur;
if ($_SESSION['intspouse'] == 1)
{
$Spouse = "X";
$SpOn = "checked";
include(_INC_DIR."updf1099int.php");
include(_INC_DIR."loadform.php");
$_SESSION['intspouse'] = 0;
}
else if ($_SESSION['intspouse'] == 2)
{
$Spouse = "";
$SpOn = "";
include(_INC_DIR."updf1099int.php");
include(_INC_DIR."loadform.php");
$_SESSION['intspouse'] = 0;
}
.
.
.
<input type="checkbox" name="Spouse" value="X" <?echo $SpOn?> onclick="<?if ($Spouse=="") $_SESSION['intspouse']=1; elseif ($Spouse=="X") $_SESSION['intspouse']=2;?>history.go(0)" tabindex='<?echo $tab++?>'>Check if this 1099-Int is for your Spouse</td>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.