亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Javascript 在 asp.net 中的每一行中僅允許在 Gridview 中選擇一個

使用 Javascript 在 asp.net 中的每一行中僅允許在 Gridview 中選擇一個

Smart貓小萌 2023-05-25 17:15:38
我想使用 JavaScript 從網格視圖的每一行中只選擇一個單選按鈕。我在 Gridview 的每一行中使用了 4 個單選按鈕。我試過了...<script>? ? ? ? ? ? function GetCheckedRows() {? ? ? ? ? ? ? ? var radio1 = null;? ? ? ? ? ? ? ? var radio2 = null;? ? ? ? ? ? ? ? var radio3 = null;? ? ? ? ? ? ? ? var radio4 = null;? ? ? ? ? ? ? ? $("#GridView1 tr").each(function () {? ? ? ? ? ? ? ? ? ? radio1 = $(this).find(".RadioButton1");? ? ? ? ? ? ? ? ? ? if (radio1.is(':checked')) {? ? ? ? ? ? ? ? ? ? ? ? radio2.checked = false;? ? ? ? ? ? ? ? ? ? ? ? radio3.checked = false;? ? ? ? ? ? ? ? ? ? ? ? radio4.checked = false;? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ? });? ? ? ? ? ? }? ? ? ? </script>]
查看完整描述

2 回答

?
MYYA

TA貢獻1868條經驗 獲得超4個贊

給每行單選按鈕一個不同的名字


<div class="row">

  <input type="radio" name="rowA" /> Label A

  <input type="radio" name="rowA" /> Label B

  <input type="radio" name="rowA" /> Label C

  <input type="radio" name="rowA" /> Label D     

</div>

<div class="row">

  <input type="radio" name="rowB" /> Label A

  <input type="radio" name="rowB" /> Label B

  <input type="radio" name="rowB" /> Label C

  <input type="radio" name="rowB" /> Label D     

</div>


查看完整回答
反對 回復 2023-05-25
?
jeck貓

TA貢獻1909條經驗 獲得超7個贊

javascript代碼


<script src="https://code.jquery.com/jquery-2.2.4.js"></script>


$(document).on('click','.radio-class',function(){

  $this = $(this);

  // uncheck all other radio inputs except this one

  $('.radio-class').not($this).prop('checked', false);

});

單選按鈕


<asp:RadioButton ID="RadioButton1" GroupName="radio-class" runat="server" />


查看完整回答
反對 回復 2023-05-25
  • 2 回答
  • 0 關注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號