Forms - RadioButtons Check and Unchecked

liunx

Guest
Hi All<br />
<br />
I have a form right know with radio buttons, is there a way to have one radio button and allow the user to uncheck it if they need to..<!--content-->Why would you want something like this? It would have the same purpose of a check box :)<br />
<br />
But if you must use radio buttons, this should be what you want:<input type="radio" onclick="this.checked=(this.checked)?false:true"><!--content-->I tryed it on it's own and it worked great tryed it in my form and no luck??<br />
<br />
<br />
<?I have a php script up here><br />
<form method="post" action="question3a.php"><br />
<table width="100%" border="0" cellspacing="2" cellpadding="2"><br />
<tr> <br />
<td width="49%"><h1>Question 3</h1></td><br />
<td width="51%"><h1>&nbsp;</h1></td><br />
</tr><br />
<tr> <br />
<td>What type of ATM do you have (manufacturer's name)</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td height="23"><br />
<input type="radio" name="radiobutton3a" value="Triton"><br />
Triton </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" name="radiobutton3a" value="NCR"><br />
NCR </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" name="radiobutton3a" value="Diebold"><br />
Diebold </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" name="radiobutton3a" value="Tidel"><br />
Tidel</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td><input type="radio" name="radiobutton3aa" value="radiobutton" onclick="this.checked=(this.checked)?false:true"><br />
Other <font size="3" face="Arial, Helvetica, sans-serif"><br />
<input type="text" name="txtOther"><br />
</font></td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td><input type="radio" name="radiobutton3a" value="DontKnow"><br />
Don't Know</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr><br />
<td>&nbsp;</td><br />
<td><input type="submit" name="Submit" value="Next"></td><br />
</tr><br />
</table><br />
</form><!--content-->you need to put it in for all radio buttons :)<!--content-->Hi there<br />
<br />
I added that line with each of my radio buttons and nothing worked once i removed the name and the value from some of the radio buttons it worked.<br />
<br />
is there a way to use that but still have a value and name to each of the radio buttons?<br />
<br />
<br />
<form method="post" action="question3a.php"><br />
<table width="100%" border="0" cellspacing="2" cellpadding="2"><br />
<tr> <br />
<td width="49%"><h1>Question 3</h1></td><br />
<td width="51%"><h1>&nbsp;</h1></td><br />
</tr><br />
<tr> <br />
<td>What type of ATM do you have (manufacturer's name)</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td height="23"><br />
<input type="radio" onclick="this.checked=(this.checked)?false:true" ><br />
Triton </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" onclick="this.checked=(this.checked)?false:true" ><br />
NCR </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" name="radiobutton3a" value="Diebold" onclick="this.checked=(this.checked)?false:true" ><br />
Diebold </td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td> <input type="radio" onclick="this.checked=(this.checked)?false:true"><br />
Tidel</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td><input type="radio" name="radiobutton3aa" value="radiobutton" onclick="this.checked=(this.checked)?false:true"><br />
Other <font size="3" face="Arial, Helvetica, sans-serif"><br />
<input type="text" name="txtOther"><br />
</font></td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr> <br />
<td><input type="radio" name="radiobutton3a" value="DontKnow" onclick="this.checked=(this.checked)?false:true"><br />
Don't Know</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr><br />
<td>&nbsp;</td><br />
<td><input type="submit" name="Submit" value="Next"></td><br />
</tr><br />
</table><br />
</form><!--content-->Hi There<br />
<br />
Thought this might be easer to read<br />
<br />
Anyway this is what i have noticed<br />
<br />
input type="radio" onclick="this.checked=(this.checked)?false:true" <br />
<br />
This works<br />
<br />
But when i add a name or value like this <br />
<br />
<input type="radio" name="radiobutton3a" value="Diebold" onclick="this.checked=(this.checked)?false:true" > <br />
This does not work<br />
<br />
Any ideas<!--content-->Thanks, never realized that. This will work, all you need to do is change the radio names for each option. It automically unchecks it, but switches between 0 and 1. The way to do this is:<script type="text/javascript"><br />
<br />
var checks = new Array<br />
<br />
function getCheck(obj) {<br />
var toUse = checks.length<br />
for(var i=0;i<checks.length;i++) {<br />
if(obj.name == checks[0]) {<br />
toUse = i<br />
break;<br />
}<br />
}<br />
if(toUse == checks.length) {<br />
checks[toUse] = new Array(obj.name,0)<br />
}<br />
if(!checks[toUse][1]) {<br />
checks[toUse][1] = 1<br />
}<br />
else {<br />
checks[toUse][1] = 0<br />
}<br />
return checks[toUse][1]<br />
}<br />
<br />
</script><br />
<br />
<input type="radio" name="radiobutton3a" value="Diebold" onclick="this.checked=0;this.checked=getCheck(this)" >Hope that it works :)<!--content-->That works Great, Thankyou so much... You have been a great help..<!--content-->sure thing, glad that someone realizes that I am here only to help others, glad to be doing my job :)<!--content-->
 
Back
Top