Change radio button based on other radio button's value

How do I deal with this behaviour:

enter image description here

Relevant HTML:

        Player 1: <input type="text" name="player1Name">
        <input type="radio" name="option1" value="X" id='option1X'/> X
        <input type="radio" name="option1" value="O" id='option1O' /> O

        Player 2: <input type="text" name="player2Name">
        <input type="radio" name="option2" value="X" id='option2X' /> X
        <input type="radio" name="option2" value="O" id='option2O'/> O


Here’s what I have tried:

const option2X = document.getElementById('option2X');
const option2O = document.getElementById('option2O');
const option1X = document.getElementById('option1X');
const option1O = document.getElementById('option1O');

function checkRadios(option1, option2, option3) {
    option1.addEventListener('click', function () {
        if(option1.checked && option2.checked)
        option3.setAttribute('checked', 'true'); 

checkRadios(option1X, option2X, option2O); 
checkRadios(option1O, option2O, option2X); 
checkRadios(option2X, option1X, option1O); 
checkRadios(option2O, option1O, option1X);

This works for the first time and then it stops working.
I checked the debugger, and the reason is that option3’s value changes somehow.
Player1’s radios are option1X and option1O.

What I want:
If an option is clicked by user A and the same option has already been taken by another user (B), then the other user’s (B’s) radio should change.
I tried changing the ‘click’ event to ‘change’ and that also didn’t work.

134 thoughts on “Change radio button based on other radio button's value”

  1. Hey! Someone in my Facebook group shared this website with us so I came to give it a look.
    I’m definitely loving the information. I’m bookmarking and will be tweeting this to my
    followers! Terrific blog and excellent design.

  2. I truly love your website.. Excellent colors & theme.
    Did you make this amazing site yourself? Please reply back as I’m hoping to create
    my own blog and would like to learn where you got this from or what the theme is called.

    Thank you!

  3. Great beat ! I would like to apprentice at the same time as you amend your
    web site, how could i subscribe for a weblog web site?
    The account helped me a applicable deal.

    I have been a little bit acquainted of this your broadcast offered vibrant transparent concept

  4. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each
    time a comment is added I get four e-mails with the same comment.

    Is there any way you can remove people from that service?

  5. Pingback: tab stromectol
  6. hello there and thank you for your info – I have definitely picked up something new from right here.
    I did however expertise several technical issues using this web site,
    since I experienced to reload the web site lots of times previous to I
    could get it to load correctly. I had been wondering if your web
    host is OK? Not that I am complaining, but slow loading instances times
    will very frequently affect your placement in google and could damage your high-quality score if advertising and
    marketing with Adwords. Anyway I’m adding this RSS to my
    e-mail and could look out for much more of your respective fascinating content.
    Ensure that you update this again very soon. scoliosis surgery scoliosis surgery

  7. Pingback: deltasone for pid
  8. Pingback: talicia medication
  9. Pingback: ivermectine
  10. Pingback: ivermectin coupon
  11. Pingback: tadalafil generic

Leave a Comment