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 8561457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:30:27+00:00 2026-06-11T16:30:27+00:00

Newbie- I want to do 2 things with these checkboxes: Use TAB key to

  • 0

Newbie- I want to do 2 things with these checkboxes:

  1. Use TAB key to tab through options, this part works
  2. As I TAB through options, I want to hit ENTER key to select that check box, this part is NOT working

Below is sample code. I am using the checkboxes as a group.

Does any one have any suggestions?

<!doctype html>
    <head>
        <title>test Radio buttons checkbox</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $('input:checkbox[name=Colors]').keypress(function(event) {
                    var keycode = (event.keyCode ? event.keyCode : event.which);
                    if (keycode == 13) {
                        Checkbox_to_RadioButton(this);
                        alert("Enter key was pressed");
                    }   
                    event.stopPropagation();
                });

                $('input:checkbox[name=Colors]').click(function(){
                    Checkbox_to_RadioButton(this);
                });
            });

            function Checkbox_to_RadioButton(box){
                $('input:checkbox[name=' + box.name + ']').each(function(){
                    if (this != box)
                        $(this).attr('checked', false);
                });
            }
        </script>
    </head>

    <body>
        <h1>test Radio buttons checkbox</h1>
        <form name="form1">
            <input type="text" id="dname" name="dname"><br>
            <input type="checkbox" id="Colors" name="Colors" value="Red" />Red<br />
            <input type="checkbox"  id="Colors" name="Colors" value="Blue" />Blue<br />
            <input type="checkbox" id="Colors"  name="Colors" value="Green" />Green<br     />
            <input type="checkbox" id="Colors"  name="Colors" value="Yellow"         />Yellow<br /> 
            <br>
        </form>
    </body>
</html>
  • 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-11T16:30:28+00:00Added an answer on June 11, 2026 at 4:30 pm

    Try this code

    <!doctype html>
    <html>
      <head>
        <title>test Radio buttons checkbox</title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $('input:checkbox[name=Colors]').keypress(function(event) {
                    var keycode = (event.keyCode ? event.keyCode : event.which);
                    if (keycode == 13) {
                        Checkbox_to_RadioButton(this,"enter");
                    }   
                    event.stopPropagation();
                });
    
                $('input:checkbox[name=Colors]').click(function(){
                    Checkbox_to_RadioButton(this,"click");
                });
            });
    
            function Checkbox_to_RadioButton(box,myEvent){
                if(myEvent == "enter")
                {
                    var $box = $(box);
                    if($box.attr('checked'))
                        $box.attr('checked',false);
                    else
                        $box.attr('checked',true);
                }
                $('input:checkbox[name=' + box.name + ']').each(function(){
                    if (this != box)
                        $(this).attr('checked', false);
                });
            }
        </script>
    </head>
    
    <body>
        <h1>test Radio buttons checkbox</h1>
        <form name="form1">
            <input type="text" id="dname" name="dname"><br>
            <input type="checkbox" id="Colors" name="Colors" value="Red" />Red<br />
            <input type="checkbox"  id="Colors" name="Colors" value="Blue" />Blue<br />
            <input type="checkbox" id="Colors"  name="Colors" value="Green" />Green<br     />
            <input type="checkbox" id="Colors"  name="Colors" value="Yellow"         />Yellow<br /> 
            <br>
        </form>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok bit of a newbie type question. I want to use Core Data, together
a newbie django question I want to use 3rd party app, but I need
I am a newbie and want to ask how load testing is done by
I'm a total newbie and want to start with php. I know some javascript
jQuery-newbie here. I want to do a simple horizontal scroll function with two buttons.
I'm a newbie at git and want to understand how to collaborate with a
I'm a newbie. I want to ask about the MVC model for separation of
I am a newbie in the iPhone dev and I want to know if
I'm a newbie in Android Development and I want to implement Spinner . My
I an newbie in html5, I want to create an a dot like image

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.