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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:06:45+00:00 2026-05-24T17:06:45+00:00

I am completely lost as to how I can solve this. I need to

  • 0

I am completely lost as to how I can solve this.
I need to create a matrix of radio buttons, column 1 to 3 and rows A to C.
A B C
1 (o) (o) (o)
2 (o) (o) (o)
3 (o) (o) (o)

<table>   
<tr> 
<td>1</td> 
<td><input type="radio" id="ljudkalla_1" name="ljudkalla_1" value="Radio A" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_2" name="ljudkalla_2" value="Radio B" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_3" name="ljudkalla_3" value="Ipod A" onclick="checkMatrixRow(this)"></td> 
</tr>
<tr> 
<td>2</td> 
<td><input type="radio" id="ljudkalla_1" name="ljudkalla_1" value="Radio A" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_2" name="ljudkalla_2" value="Radio B" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_3" name="ljudkalla_3" value="Ipod A" onclick="checkMatrixRow(this)"></td> 
</tr>
<tr> 
<td>3</td> 
<td><input type="radio" id="ljudkalla_1" name="ljudkalla_1" value="Radio A" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_2" name="ljudkalla_2" value="Radio B" onclick="checkMatrixRow(this)"></td> 
<td><input type="radio" id="ljudkalla_3" name="ljudkalla_3" value="Ipod A" onclick="checkMatrixRow(this)"></td> 
</tr>
</table>

<script>
// radio buttons
var columns = new    Array('ljudkalla_1','ljudkalla_2','ljudkalla_3');

function getSelectedIndex(array) {
for (var i=0; i<array.length; i++) {
    if (array[i].checked) return i;
}
}

function checkMatrixRow(input) {

var n = getSelectedIndex(input.form[input.name]); // index of selected button in a radio group (= row number)   


for (var i=0; i<columns.length; i++) {
    if (columns[i] != input.name) {
        input.form[columns[i]][n].checked = false;
    }
}
}
</script>

I should only be able to choose one button per row and column, so if I have chosen A1 and then click on B1, the first one should uncheck. The big issue is really the C column. In this column I should be able to choose all three, C1 C2 and C3, but same thing here if I have chosen C2 and then check A2 the first one should uncheck.
I have been scanning the internet for days and I cannot find anything, so if anyone knows of a tutorial or just some information on how to solve this I would be deeply grateful.

Or perhaps it is not possible to do it this way?

Thanks

Linda

  • 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-24T17:06:46+00:00Added an answer on May 24, 2026 at 5:06 pm

    I some how stumbled upon the answer while playing with it O_o

    Demo

    Basically you use the class name in conjunction with the name attribute to get a multi-axis radio button. Then the radio buttons are reset based on the same name and you reset the others based on class name. Elegant yet simple.

    Markup


    <table>   
    <tr> 
    <td>1</td> 
    <td><input type="radio" class="ljudkalla_1" name="ljudkalla_1" value="Radio A"></td> 
    <td><input type="radio" class="ljudkalla_2" name="ljudkalla_1" value="Radio B"></td> 
    <td><input type="radio" class="ljudkalla_3" name="ljudkalla_1" value="Ipod A"></td> 
    </tr>
    <tr> 
    <td>2</td> 
    <td><input type="radio" class="ljudkalla_1" name="ljudkalla_2" value="Radio A"></td> 
    <td><input type="radio" class="ljudkalla_2" name="ljudkalla_2" value="Radio B"></td> 
    <td><input type="radio" class="ljudkalla_3" name="ljudkalla_2" value="Ipod A"></td> 
    </tr>
    <tr> 
    <td>3</td> 
    <td><input type="radio" class="ljudkalla_1" name="ljudkalla_3" value="Radio A"></td> 
    <td><input type="radio" class="ljudkalla_2" name="ljudkalla_3" value="Radio B"></td> 
    <td><input type="radio" class="ljudkalla_3" name="ljudkalla_3" value="Ipod A"></td> 
    </tr>
    </table>
    

    jQuery


    $("input").click(function(){
        $("input."+this.className).not($(this)).each(function(){
            this.checked = false;
        });
    });
    

    Edit


    Demo 2

    I added another cool little feature to this with the following code

    $("input").click(function(){
        $("input."+this.className).not($(this)).each(function(){
            this.checked = false;
        });
        $("input:not([name='"+this.name+"'])").each(function(){
            if ($("input[name='"+this.name+"']:checked").length < 1)
                if($("input."+this.className+":checked").length < 1)
                    this.checked = true;
        });
    });
    

    This enables it to automatically change a radio button selection if another selection deselects it… maybe you should just see the demo. 😛 It’s a little hard to explain I guess.

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

Sidebar

Related Questions

Im completely lost with this one. Ok so I create a button with CSS,
How can I access this element: <input type=submit value=Save as XML onclick=some code goes
I am completely lost on this; I am using NodeJS to fetch a JSON
This is very stupid but I seem to be completely lost trying to test
I'm completely lost as to how or why this error is displaying when I
Hey all, I am completely lost on this one. I found a code snippet
I am completely new to flash. We need to load a binary file from
I am not completely sure about the following table alt text http://files.getdropbox.com/u/175564/algTranslation.png The table
I'm completely stuck and need your help... I've created a webservice stub with jaxb
I'm struggling with a deployment issue which leaves me completely lost. It goes like

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.