Opera 3.10: JavaScript Reports Unchecked Radio Buttons as Checked

See also: Opera JavaScript Flaw--Cannot Select a Radio Button Properly with JavaScript

This page demonstrates an apparent flaw in the Opera 3.10 browser. This page is an update to an earlier flaw found and corrected in Opera 3.0; unfortunately, another flaw was uncovered as soon as the first one was fixed (which is what makes software development so enjoyable, right?).

The example below includes a form containing a pair of radio buttons and a JavaScript fragment intended to determine whether one of the buttons is checked. The JavaScript fragment erroneously reports that both radio buttons are checked.


Form and Demonstration

The form in this section has a pair of radio buttons. When this page is viewed in Opera 3.10, the script reports that both buttons are checked. Testing revealed that the script will report both buttons as checked even if neither button is checked.

(Note that the page will not be updated if you select a different radio button.)

One Two

Regardless of which button is checked, the JavaScript-generated message below reports both buttons are checked when this page is viewed in Opera 3.10.

Message generated by JavaScript:


Source

The form is defined like this:

<FORM NAME="frmTest">
    <INPUT TYPE=radio NAME="rbtnRadioTest" VALUE="One" CHECKED OnClick="0">One
    <INPUT TYPE=radio NAME="rbtnRadioTest" VALUE="Two" OnClick="0">Two
</FORM>

Here is a view of the JavaScript source that generates the message above.

<SCRIPT LANGUAGE="JavaScript">

    // <!--

    if (document.frmTest.rbtnRadioTest[0].checked == true)
        document.write ("Radio button 'One' is checked.");
    else
        document.write ("Radio button 'One' is not checked.");

    if (document.frmTest.rbtnRadioTest[1].checked == true)
        document.write ("Radio button 'Two' is checked.");
    else
        document.write ("Radio button 'Two' is not checked.");

    // -->

</SCRIPT>

Discovered By

This flaw was discovered by Charles L. Taylor, who also prepared this example.

Last update: 10 Oct 1999 -- (Copyright) -- (Contact)