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
https://forums.phpfreaks.com/topic/74690-solved-help-with-php-in-onclick/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.