简体   繁体   中英

how to pass radiobutton value using ajax from one jsp to another jsp

(document).ready(function() {
    $("input[type='radio']").click(function() {
        var radioVal = $("input[name='price']:checked").val();
    });
}

I need to pass radioVal value to another jsp

Please Take the help of Following Example.

page1.jsp

<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<script>
$(document).ready(function () {
    var radioVal;
     $("input[type='radio']").click(function() {
             radioVal = $("[name=radio]:checked").val();
             alert(radioVal);
             $.post("page2.jsp", {"processId": radioVal })
        });

});

</script>
<input type="radio" name="radio" value="first"/> 1 <br/>
<input type="radio" name="radio" value="second"/> 2 <br/>

page2.jsp

<%
System.out.println(request.getParameter("processId"));
%>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM