Jump to content

Checkbox - Value is always on, even when checkbox is unselected.


MadnessRed

Recommended Posts

Hi, I have a registration form, where when a field changes the image next to it changes, hard to explain so I will put the code below.

 

				<tr>
				<td>Username </td>
				<td>
					<input name="character" type="text" name="character" id="playername" style="width:150px;" onkeyup="Javascript: document.getElementById('usercheck').innerHTML = '<image src=\'game/check.php?check=user&username='+getElementById('playername').value+'&s='+getElementById('s').value+'\' />';" />
				</td>
				<td><span id="usercheck"><image src="game/check.php?check=user&img=bad&s=1" /></span></td>
			</tr>

 

That works fine, however i have a checkbox, and my problem is, it always gives a value of on, or my onchange function doesn't work.

 

So basically there is a cross, when they click the I agree checkbox, that becomes a tick, then when they un-select it, it is still a tick,

 

The reg form is below.

http://darkevo.org/reg.html

 

Here is the checkbox row,

 

				<tr>
				<td colspan="2">
					<input name="rgt" id="rgt" type="checkbox" "onclick="Javascript: document.getElementById('toscheck').innerHTML = '<image src=\'game/check.php?check=tos&tos='+getElementById('rgt').value+'&s='+getElementById('s').value+'\' />';" />
					I accept the TOS
				</td>
				<td><span id="toscheck"><image src="game/check.php?check=user&img=bad&s=1" /></span></td>
			</tr>
			<tr>

 

Here is the check.php code relating to that section.

 

}elseif($_GET['check'] == 'tos'){
if($_GET['tos'] != 'on'){
	$good = false;
}else{
	$good = true;
}
}

 

if($unused){
$image = "../check/no.gif";
}elseif ($good){
$image = "../check/ok.gif";
}else{
$image = "../check/err.gif";
}

//Load the image
$img = ImageCreateFromGif($image);

//Convert to PNG and send it to browser
if($img) {
header("Content-Type: image/gif");
ImageGIF($img);

//Clean-up memory
ImageDestroy($img);
}
?>

 

I know that the php file works though because

check.php?check=tos&tos=off&s=1

gives a cross,

Link to comment
Share on other sites

What happens if you temporarily remove this section:

 

onkeyup="Javascript: document.getElementById('usercheck').innerHTML = '<image src=\'game/check.php?check=user&username='+getElementById('playername').value+'&s='+getElementById('s').value+'\' />';"

 

 

 

 

 

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.