Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Checked radio button doesn't uncheck

Reply
Thread Tools

Checked radio button doesn't uncheck

 
 
Ken Loomis
Guest
Posts: n/a
 
      12-31-2003
Hello:

On a web page I check the value of a cookie and set one of two radio
buttons accordingly.

function setRadioForm() {
var myCookie = document.cookie;
var OpenOnly = myCookie.substring(9);
if (OpenOnly == "True") {
document.ViewOptions.Open.checked = true;
}
else {
document.ViewOptions.All.checked = true;
}
}

<body onload="setRadioForm()">


This works fine. The correct radio button appears checked when the
form opens. However, when the user checks one of the buttons (usually
the unchecked one), both buttons remain checked.

Here's the code on the form:

<form name='ViewOptions">
<input type="radio" name="Open" value="True"
onclick="setCookie("True")> Always, show me open items only.
<input type="radio" name="All" value="False"
onclick=setCookie("False")>Always show me all items, open and closed.
</form>

The onclick fires correctly, but the button which was not clicked
remains checked. Am I doing something wrong or is this a limitation
in the browser/code?

--
Ken





 
Reply With Quote
 
 
 
 
Ken Loomis
Guest
Posts: n/a
 
      12-31-2003
John:

Thank you. Perfect!

Ken


On Wed, 31 Dec 2003 01:10:36 GMT, "johkar" <>
wrote:

>When you have a group of radio buttons (I.E. only one can be selected), you
>need to name them the same. The checked value, if any, will be the only one
>returned under that name. Since they are named the same you need to access
>them like so: 1st radio button: document.ViewOptions.Open[0].checked 2nd
>radio button: document.ViewOptions.Open[1].checked
>
>John
>
>"Ken Loomis" <> wrote in message
>news:.. .
>> Hello:
>>
>> On a web page I check the value of a cookie and set one of two radio
>> buttons accordingly.
>>
>> function setRadioForm() {
>> var myCookie = document.cookie;
>> var OpenOnly = myCookie.substring(9);
>> if (OpenOnly == "True") {
>> document.ViewOptions.Open.checked = true;
>> }
>> else {
>> document.ViewOptions.All.checked = true;
>> }
>> }
>>
>> <body onload="setRadioForm()">
>>
>>
>> This works fine. The correct radio button appears checked when the
>> form opens. However, when the user checks one of the buttons (usually
>> the unchecked one), both buttons remain checked.
>>
>> Here's the code on the form:
>>
>> <form name='ViewOptions">
>> <input type="radio" name="Open" value="True"
>> onclick="setCookie("True")> Always, show me open items only.
>> <input type="radio" name="All" value="False"
>> onclick=setCookie("False")>Always show me all items, open and closed.
>> </form>
>>
>> The onclick fires correctly, but the button which was not clicked
>> remains checked. Am I doing something wrong or is this a limitation
>> in the browser/code?
>>
>> --
>> Ken
>>
>>
>>
>>
>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
uncheck radio group cerr Javascript 7 11-06-2011 07:58 PM
how to uncheck other checkboxes when one checkbox is checked in a grid? pavankumarkavety ASP .Net 0 05-22-2008 08:46 AM
Swap image with check/uncheck of Radio Button lemat@attglobal.net Javascript 2 01-09-2007 02:29 PM
Swap image with check/uncheck of Radio Button lemat@attglobal.net HTML 0 01-08-2007 01:51 PM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57