radio buttons disable second set with ID and not Value

  • Mozzi
  • Student
  • Student
  • Mozzi
  • Posts: 70

Post 3+ Months Ago

Hi..

I have 2 groups of radio buttons..

I can manage to make one set be disabled via a selection.. but i can only get this right with the VALUE...

Is it possible to use the radio id to do the same??

Just use the a link for jquery

Code: [ Select ]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery.min.js"></script>


</head>
<body>

<br />
<br />
<div>  1 - <input type="radio" id="1" value="11" /> </div>
<div>  2 - <input type="radio" id="2" value="22"/> </div>
<div>  3 - <input type="radio" id="3" value="33"/> </div>
<br />
<br />
<div>  1 - <input type="radio" id="1" value="11" /> </div>
<div>  2 - <input type="radio" id="2" value="22" /> </div>
<div>  3 - <input type="radio" id="3" value="33" /> </div>

 <script>
$("input:radio").click(function() {
  var val = $(this).val();
  $(this).siblings("input:radio").attr("disabled","disabled");
  $("input:radio[value='" + val + "']").not(this).attr("disabled","disabled");
});
  </script>
  
</body>
</html>
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5. <script src="jquery.min.js"></script>
  6. </head>
  7. <body>
  8. <br />
  9. <br />
  10. <div>  1 - <input type="radio" id="1" value="11" /> </div>
  11. <div>  2 - <input type="radio" id="2" value="22"/> </div>
  12. <div>  3 - <input type="radio" id="3" value="33"/> </div>
  13. <br />
  14. <br />
  15. <div>  1 - <input type="radio" id="1" value="11" /> </div>
  16. <div>  2 - <input type="radio" id="2" value="22" /> </div>
  17. <div>  3 - <input type="radio" id="3" value="33" /> </div>
  18.  <script>
  19. $("input:radio").click(function() {
  20.   var val = $(this).val();
  21.   $(this).siblings("input:radio").attr("disabled","disabled");
  22.   $("input:radio[value='" + val + "']").not(this).attr("disabled","disabled");
  23. });
  24.   </script>
  25.   
  26. </body>
  27. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

My first observation is that you cannot have multiple elements with the same id. While the same class can be used multiple times on an element, an id is supposed to be unique and can only be used once. In your example above you are using the same id twice for multiple sets of elements, this is not correct. Is there any particular reason you are having them set as the same ID. What exactly are you trying to do?

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 109 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.