Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1115973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:14:09+00:00 2026-05-17T03:14:09+00:00

I want to select a radio button from javascript. I am using this simple

  • 0

I want to select a radio button from javascript. I am using this simple html file to test the issue. The code below works correctly on firefox and chrome, however it does not work in IE (no version works). I would like to know why the supplied code does not work on IE, and how to select a radio button in IE?

<html>
<head>
    <script type="text/javascript">
        function chooseOne()
        {
            var randomChoice = Math.round(Math.random() * 2);

            if(randomChoice == 0)
            {
                document.getElementById("test0").checked = true;
            }
            else if (randomChoice == 1)
            {
                document.getElementById("test1").checked = true;
            }
            else
            {
                document.getElementById("test2").checked = true;
            }
        }
    </script>
</head>
<body>
    <input type="radio" id="test0" name="test" value="a" /> A<br />
    <input type="radio" id="test1" name="test" value="b" /> B<br />
    <input type="radio" id="test2" name="test" value="c" /> C<br />
    <input type="button" name="click" value="CHOOSE" onclick="javascript:chooseOne()" />
</body>

Thanks in Advance,
Spi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T03:14:09+00:00Added an answer on May 17, 2026 at 3:14 am

    First of all, you should give all your radio buttons the same name, otherwise they will act as if they are independent buttons:

    <input type="radio" name="test" id="test0" value="a" /> A<br />
    <input type="radio" name="test" id="test1" value="b" /> B<br />
    <input type="radio" name="test" id="test2" value="c" /> C<br />
    

    I’m guessing this is also the source of your problem. Further, once you do this, you only need to set one radio button’s checked to true, that will automatically remove the selection from other buttons.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select only one radio button but I cant do this. Here
i have this lists, and i want select li element from jquery when the
i have big table with many html items such as select, textbox, radio-button, checkbox.
I want to get the data from radio button when I submit it, but
I want to have a user select tags with a radio button widget, not
I want to display a select box based on a radio button selection. There
1) when i clicked to any checkbox, a) i want to select radio in
i have users table and i have posts table i want select from users
The following code uses the DB extention provided by PEAR. I want a radio
I'm trying to do a Greasemonkey script to auto-select a radio button. The poll

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.