MadnessRed Posted January 10, 2009 Share Posted January 10, 2009 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 https://forums.phpfreaks.com/topic/140299-checkbox-value-is-always-on-even-when-checkbox-is-unselected/ Share on other sites More sharing options...
bubbasheeko Posted January 10, 2009 Share Posted January 10, 2009 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 https://forums.phpfreaks.com/topic/140299-checkbox-value-is-always-on-even-when-checkbox-is-unselected/#findComment-734170 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.