2 radio buttons

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
killbaz
Forum Newbie
Posts: 12
Joined: Mon Feb 02, 2009 4:44 pm

2 radio buttons

Post by killbaz »

Hello to all...

I made 2 radio buttons

<input type="radio" name="rad" value="val">
<input type="radio" name="rad2" value="val2">


How can i make when i will check the first radio button , automatically check the second?

thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: 2 radio buttons

Post by pickle »

Give them the same name.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
killbaz
Forum Newbie
Posts: 12
Joined: Mon Feb 02, 2009 4:44 pm

Re: 2 radio buttons

Post by killbaz »

not working :(

but i don't want like this :(

Code: Select all

<input type="radio" name="radio1" value="1" onclick="selectAnother();" id="radio1">
<input type="radio" name="radio2" value="1" id="radio2">
<script>
      function selectAnother()
      {
         var radio1 = document.getElementById('radio1');
         var radio2 = document.getElementById('radio2');
         if(radio1.checked)
         {
            radio2.checked = true;
         }
      }
</script>

edit:
i didnt test correctly :))
it worked ... but not like i want to , but still, it's good :D thx :)
Post Reply