简体   繁体   English

使用按钮单击重定向到所选单选按钮上的不同页面

[英]redirect to different pages on selected radio button using button click

The following image is a pop up that details risk warnings and then asks users to choose one of the two radio buttons. 下图是一个弹出窗口,详细说明了风险警告,然后要求用户选择两个单选按钮中的一个。 When 'I agree'(Submit) button is clicked, it should redirect to different pages based on which radio button is selected. 当“我同意”(提交)按钮被单击时,它应根据选择的单选按钮重定向到不同的页面。 The submit button has a jquery class.Can someone help me with a jquery code to check which radio button is selected and redirect to different pages? 提交按钮有一个jquery类。有人帮我用jquery代码检查选择了哪个单选按钮并重定向到不同的页面?
IMG

The html is below, 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>

The jquery class is below 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();
            });

Try this 尝试这个

Html 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 使用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();
            });

Check fiddle here 在这里检查小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何根据使用单个表单选择的单选按钮来修复代码以转到不同页面 - How to fix the code to go for different pages according to radio button selected using single form 选择单选按钮时启用单击按钮 - Enable click button when a radio button is selected 触发按钮选择单选按钮时单击 - Trigger Button Click when Radio button is selected 如果选择或不选择单选按钮的不同值 - different values for radio button if selected or not 如何重定向到angular2中不同组件的后退按钮单击上的页面? - How to redirect to the pages on back button click of different components in angular2? 选择单选按钮后重定向到特定页面 - Redirecting to specific pages after radio button is selected 每个单选按钮都会通过“ onclick”而不是“ submit”自动重定向到不同选择的不同页面 - Each radio button automatically redirect to the different pages on different selections through 'onclick' and not from 'submit' 验证是否已选中所有单选按钮,或者验证按钮是否未单击 - Validate that ALL radio buttons are selected or NOT on button Click 根据选中的单选按钮移至其他页面 - move to different pages based on the checked radio button 是否可以在不同页面中获取单选按钮的值? - Is it possible to get the values of radio button in different pages?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM