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

前端 未结 1 1058
栀梦
栀梦 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

    And in your Controller add parameter @RequestParam List radioValueArrya in your method

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