how to pass the list of radio buttons name to spring controller and show them to the success page

前端 未结 1 1059
栀梦
栀梦 2021-01-26 14:30

I have a list of radio buttons while selecting I am facing one issue with below code as i am getting only value of first radio button in my js function for others (i mean other

相关标签:
1条回答
  • 2021-01-26 15:07
    var radioValueArrya = [];
    $("#r1").each(function() {
            if($(this).is(':checked'))
            radio1=$(this).val();
            radioValueArrya.push(radio1); 
            alert("radio select values"+radio1);
        });
    
    
    
     $("#r2").each(function() {
            if($(this).is(':checked'))
                radio2=$(this).val();
                radioValueArrya.push(radio2);
            alert("radio select values"+radio2);
        });   
    // controller call 
     $("#divid").load("${contextPath}/actionName?kRadio="+escape(radio1)  +"" +
                        "&sRadio="
                        +"" +escape(radio2)+"&radioValueArrya="+radioValueArrya); 
    

    And in your JSP file use <input type="hidden" id="radioValueArrya" name="radioValueArrya"/>

    And in your Controller add parameter @RequestParam List<String> radioValueArrya in your method

    0 讨论(0)
提交回复
热议问题