Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello,

I have a web form which contains two radio button groups.

The first group contains two radio button for category eg:-open and reserved.

The second group contains sc,st,obc,etc radiobutton.

The condition is if I click on open radio button second groups radiobutton should get unchecked.

How can I do this?

Please help.
Posted
Updated 24-Nov-11 23:56pm
v2

What you describe is just an indication of wrong UI design. Even for a final user it could be counter-intuitive. Perhaps you did not define groups correctly or should use some different UI design idea.

—SA
 
Share this answer
 
if (RadioButtonList1.Items[0].Selected == true || RadioButtonList1.Items[1].Selected == true)
{
while(i >= RadioButtonList2.Items.Count)
RadioButtonList2.Items[i].Selected = false;
i++;
}
if (RadioButtonList2.Items[0].Selected == true || RadioButtonList2.Items[1].Selected == true)
{
while(i >= RadioButtonList1.Items.Count)
RadioButtonList1.Items[i].Selected = false;
i++;
}


Try the above code. The logic is there, just explore it.

Please mark this as correct if it fixed your problem.

Best regards,
Eduard
 
Share this answer
 
v2
Comments
Dalek Dave 25-Nov-11 5:56am    
Good Answer.
my solution

HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <title>Untitled</title>
<script type="text/Javascript">
// Enforce Yes/No fields in eval form
function uncheck_yesno(obj)
{
  if (!obj)
  {
    alert(obj + ' does not exist');
    return false;
  }
  
  for (var i=0; i < obj.length; i++)
  obj[i].checked = false;
}

function check_yesno(obj)
{
  if (!obj)
  {
    alert(obj + ' does not exist');
    return false;
  }
  
  for (var i=0; i < obj.length; i++)
  {
    if (obj[i].value==1)
    {
      obj[i].checked = true;
    }
  }
}
</script>
</head>
<body>

<form action="" name="eval_form" method="POST">
<table border="0" width="100%" cellspacing="2" cellpadding="3">
  <tr class="table-head" align="center">
    <td></td>
    <td></td>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    <td>8</td>
    <td>9</td>
    <td>10</td>
  </tr>
  <tbody class="table-body">
  <tr class="alt1" align="center">
    <td>Lack of Exercise</td>
    <td>
      Yes: <input type="radio" name="lack_exercise" value="1"  önclick="check_yesno(document.eval_form.lack_exercise_r)">
      No: <input type="radio" name="lack_exercise" value="0" checked="yes"  önclick="uncheck_yesno(document.eval_form.lack_exercise_r)">
    </td>
    <td><input type="radio" name="lack_exercise_r" value="1"  önclick="alert(this.name)"></td>
    <td><input type="radio" name="lack_exercise_r" value="2"></td>
    <td><input type="radio" name="lack_exercise_r" value="3"></td>
    <td><input type="radio" name="lack_exercise_r" value="4"></td>
    <td><input type="radio" name="lack_exercise_r" value="5"></td>
    <td><input type="radio" name="lack_exercise_r" value="6"></td>
    <td><input type="radio" name="lack_exercise_r" value="7"></td>
    <td><input type="radio" name="lack_exercise_r" value="8"></td>
    <td><input type="radio" name="lack_exercise_r" value="9"></td>
    <td><input type="radio" name="lack_exercise_r" value="10"></td>
    
  </tr>
</tbody></table>
</form>


</body>
</html>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900