Js控制CheckBox单选

protected void InformationGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        CheckBox cbx = e.Row.FindControl("cbxName") as CheckBox;
        try
        {

           //传送CheckBoxID
            cbx.Attributes.Add("onclick", "ChangeGet(" + cbx.ClientID + ")");
        }
        catch
        {
        }
    }

    <script language="javascript">

//接收传送的ID
function ChangeGet(SelectCheckBox)
{

//找所有input控件
  var objs = document.getElementsByTagName("input");
  for(var i=0; i<objs.length; i++)
    {
        if(objs[i].type.toLowerCase() == "checkbox" )

        //设置找到的CheckBox控件为false
        objs[i].checked = false;
    }

   //把选中的CheckBox控件设置为true;
   document.getElementById(SelectCheckBoxID).checked = true;
}

</script>

原文地址:https://www.cnblogs.com/zhc088/p/677478.html