在JavaScript中回发后如何保持单选按钮处于选中状态?

时间:2020-07-17 13:26:05

标签: javascript asp.net popup radio-button

有必要选中一个选中的单选按钮,并且对于每个单选按钮,应弹出其自己的表单。

RadioButton:

<asp:RadioButtonList id="RadioButtonList1" runat="server">
  <asp:ListItem value="Green"  runat="server"  class="radioOpenPopup" data-mfp-src="#form-popup"/>
  <asp:ListItem value="Red" runat="server" class="radioOpenPopup" data-mfp-src="#form-popup2"/>
  <asp:ListItem value="Yellow" runat="server" class="radioOpenPopup" data-mfp-src="#form-popup3"/>
</asp:RadioButtonList>

弹出窗口:

<div id="form-popup" class="white-popup mfp-hide">
   <div runat="server" action="#">
      <p>The first radiobutton</p>
   </div>
</div>
<div id="form-popup2" class="white-popup mfp-hide">
   <div runat="server" action="#">
      <p>The second radiobutton</p>
   </div>
</div>
<div id="form-popup3" class="white-popup mfp-hide">
   <div runat="server" action="#">
      <p>The third radiobutton</p>
   </div>
</div>

弹出样式:

.white-popup {
  position: relative;
  background: #FFF;
  padding: 20px;
  width: auto;
  max-width: 500px;
  margin: 20px auto;
}

脚本初始化:

<script type="text/javascript">
  $('.radioOpenPopup').magnificPopup({
    type:'inline',
    closeBtnInside: true
  });
</script>

让我说明一下: 当我选择“绿色”值时,将弹出“窗体”,但此后,该值将不被选中 form popup

radiobutton

0 个答案:

没有答案