Results 1 to 2 of 2

Thread: radio button checked issue on IE

  1. #1
    Join Date
    Sep 2006

    radio button checked issue on IE

    Created a set radio buttons on a JSP.

    <input type="radio" id="radio1" name="test" value="A" />AAA
    <input type="radio" id="radio2" name="test" value="B" />BBB

    At the end of the page, there is a section of javascripts:

    //diplay caption
    var radio = document.getElementById("radio1");

    if (radio.checked) {
    alert("radio is checked");

    The sequence of the action is like this: I first clicked radio1, then launched another web page. Next, I clicked on the browser's BACK icon to go back to the original page. The radio1 was still shown being checked.

    If this was done on Firefox, everything went well and the message box displayed: radio is checked

    But, if it was the IE (9), this message did not show up.

    To summarize: after leave the page, then come back, even if the radio1 radio button is shown still checked, on IE, the javascript: radioControl.checked failed to work.

    Expecting, radioControl.checked == true

    How to make it work?


  2. #2
    Join Date
    Aug 2008
    I think this fails in IE because the checkbox is re-checked (because the browser remember it's state when navigating back) after the page has loaded and the scripts has been executed.

    Try executing that code in a function with a short delay using setTimeout().

    Edit: actually, it's probably better to execute that code in the onload event.
    Last edited by ReFreezed; 10-22-2012 at 06:30 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center