单击第一组的单选按钮时,取消选中第二组的所有单选按钮 [英] uncheck all radiobutton of second group when first group's radio button clicked

查看:114
本文介绍了单击第一组的单选按钮时,取消选中第二组的所有单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个包含两个单选按钮组的Web表单.

第一组包含两个类别的单选按钮,例如:-打开和保留.

第二组包含sc,st,obc等单选按钮.

条件是,如果我单击打开的单选按钮,则第二组单选按钮应该未被选中.

我该怎么办?

请帮忙.

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.

推荐答案

您所描述的只是UI设计错误的指示.即使对于最终用户,这也可能违反直觉.也许您没有正确定义组,或者应该使用一些不同的UI设计思路.

—SA
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


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


我的解决方案

my solution

<!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>


这篇关于单击第一组的单选按钮时,取消选中第二组的所有单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆