2014-01-09 81 views
0

以下图像是弹出窗口,其中详细描述了风险警告,然后要求用户选择两个单选按钮中的一个。当点击“我同意”(提交)按钮时,它应该根据所选单选按钮重定向到不同的页面。提交按钮有一个jQuery类。有人可以帮助我使用jQuery代码来检查哪个单选按钮被选中并重定向到不同的页面?
IMG http://i43.tinypic.com/2aeuqtf.png使用按钮单击重定向到所选单选按钮上的不同页面

的HTML低于,

<div id="mask"> 
    </div> 
    <!-- create white empty box --> 
    <div id="boxes" class="bodytext"> 
     <!-- things that go in the box --> 
     <div id="dialog" class="window"> 
      <strong>Disclaimer and Risk Warnings</strong> 
      <br /> 
      <br /> 
      <div class="bodytext" style="overflow: auto; height: 160px; width: 500px;  border: activeborder 1px solid;">     
      </div> 
      <br/> 
      <strong> Please select the user type that applies to you</strong> 
      <br/>    
      <asp:RadioButtonList ID="RadioButtonList1" runat="server"> 
      <asp:ListItem>Private Clients</asp:ListItem> 
      <asp:ListItem>Professional Intermediaries</asp:ListItem> 
      </asp:RadioButtonList>    

      <p> 
       <input id="AcceptButton" type="button" value="I Agree" class="close" style="margin-left: 215px" /> 
      </p> 
     </div> 
    </div> 

jQuery的类低于

   $('.window .close').click(function (e) { 

       $.cookie("CamSession1", "CAM");     
       if ($('#Private Clients').is(':checked')) { 
        window.location.replace("http://stackoverflow.com"); 
       } 
       else if ($('#Professional Intermediaries').is(':checked')) { 
        window.location.replace("http://exchange.com"); 
       } 
       e.preventDefault(); 
       $('#mask').hide(); 
       $('.window').hide(); 
      }); 
+0

后呈现RadioButtonList的 – Satpal

+1

的你为什么要使用RUNAT服务器单选按钮HTML? –

+0

没有特别的原因,我以为我会在后面的代码做重定向。但它已经有一个jQuery类来隐藏它在创建之前创建的遮罩,所以我正在考虑在jquery类中添加重定向。我应该使用输入类型的收音机吗? – danny

回答

2

试试这个

的Html

<div id="mask"> 
    </div> 
    <!-- create white empty box --> 
    <div id="boxes" class="bodytext"> 
     <!-- things that go in the box --> 
     <div id="dialog" class="window"> 
      <strong>Disclaimer and Risk Warnings</strong> 
      <br /> 
      <br /> 
      <div class="bodytext" style="overflow: auto; height: 160px; width: 500px;  border: activeborder 1px solid;">     
      </div> 
      <br/> 
      <strong> Please select the user type that applies to you</strong> 
      <br/>    
      <input type="radio" name="rdotnc" id="rdo1" />Private Clients 
      <input type="radio" name="rdotnc" id="rdo2"/>Professional Intermediaries 
      </asp:RadioButtonList>    

      <p> 
       <input id="AcceptButton" type="button" value="I Agree" class="close" style="margin-left: 215px" /> 
      </p> 
     </div> 
    </div> 

的Javascript

$('.window .close').click(function (e) { 
       //$.cookie("CamSession1", "CAM"); 
       if ($('#rdo1').is(':checked')) { 
        window.location.replace("http://www.stackoverflow.com"); 
       } 
       else if ($('#rdo2').is(':checked')) { 
        window.location.replace("http://www.exchange.com"); 
       } 
       $('#mask').hide(); 
       $('.window').hide(); 
      }); 

检查小提琴here

相关问题