Saturday, 23 August 2014

JavaScript- onClick enable/disable radio buttons of same id but diffrent name

<script type="text/javascript">
  function Miracle() {
 var radio=document.getElementById('A');
 var len=form.A.length;
  for(var i=0; i<len; i++) {
  if(form.A[i].checked) {
  form.A[i].disabled=false; }
else
   { form.A[i].disabled=true; }
              } }
 </script>

<html>
<form id="form" name="form" method="post" action="action.php">
  <p>
    <label>
      <input type="radio" name="Radio1" value="radio" id="A" />
      Radio</label>
    <br />
    <label>
      <input type="radio" name="Radio2" value="radio" id="A" />
      Radio</label>
    <br />
    <label>
      <input type="radio" name="Radio3" value="radio" id="A" />
      Radio</label>
    <br />
    <label>
      <input type="radio" name="Radio4" value="radio" id="A" />
      Radio</label>
    <br />
    <label>
      <input type="radio" name="Radio5" value="radio" id="A" />
      Radio</label>
    <br />
    <label>
      <input type="radio" name="Radio6" value="radio" id="A" />
      Radio</label>
    <br />
  </p>
</form>

</html>

No comments:

Post a Comment