2014-01-09 37 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

相關問題