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

  • SEARCH
  • Home
  • 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 8889429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:15:39+00:00 2026-06-14T22:15:39+00:00

<style> .chb { width: 30px; } </style> <script type=text/javascript src=jquery-1.5.2.js></script> <script> $(.chb).each(function() { $(this).change(function()

  • 0
<style>
    .chb
    {
        width: 30px;
    }
</style>

<script type="text/javascript" src="jquery-1.5.2.js"></script>
<script>
    $(".chb").each(function() {
        $(this).change(function() {
            $(".chb").attr('checked',false);
            $(this).attr('checked',true);
        });
    });
</script>

<form action="demo_form.asp">
    <input type="checkbox" name="vehicle" value="Bike" class ="chb"> I have a bike<br>
    <input type="checkbox" name="vehicle" value="Car" checked="checked" class="chb"> I have a car <br>
</form>

The above coding contains two check boxes with radio button functionality. This works fine. But how to do this with javascript without using the jquery. How to achieve this.

  • 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-06-14T22:15:40+00:00Added an answer on June 14, 2026 at 10:15 pm

    If you concern only about functionality and you have lot of checkboxes this is an easy solution.

    <script>
        function func(checkBox) {
            var inputs = document.getElementsByTagName("input");
            for(var j = 0; j < inputs.length; j++) {
              if(inputs[j].type == "checkbox" && (inputs[j].className == "chb")){
                 inputs[j].checked = false;
              }     
            }
            checkBox.checked = true;
        }
    </script>
    

    Now add onclick events to your all checkboxes as below.

    <input type="checkbox" name="vehicle" value="Bike" class ="chb" onclick="func(this);"> I have a bike<br>
    <input type="checkbox" name="vehicle" value="Car" checked="checked" class="chb" onclick="func(this);"> I have a car <br>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normal style <a href="#" id="myLink" onclick="myFunc();">click me</a> function myFunc() { alert('hello!'); } jQuery style
/* Style 1 */ .myclass { background:#ff0; border:1px solid #ff0 } #myid { width:80px;
.getProperty(style) outputs TestObject(Ref:RemoteProxyReference{testContext:af4e390002a336, objectId:3171, testObjectClass:TestObject}) while to[0].getProperties() outputs text hash where key style is
Flash-style Tween/Easing Functions in C# I came across this post on the internet today.
Im attempting to style this plugin into my rails 3.2 app and having some
How do I style width for -webkit only? All of my select boxes are
I want to style selected text differently, and I'm using ::selection to achieve that.
CGI-style perl scripts are hard to test in this style: def test_it_says_hello_to_a_person get '/home.pl',
from style that looks like this: ul#menu { padding: 0 0 2px; position: relative;
Our style guide says (for whatever reason that isn't important to this question) no

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.