how can i pass value from javascript to a java class in struts2?

前端 未结 5 994
醉酒成梦
醉酒成梦 2020-12-21 18:15
function redirect(id){
alert(id);

document.forms[\"AddToCart\"].submit();
}

This is my javascript. How can i pass the value of \'id\' into AddToCa

5条回答
  •  爱一瞬间的悲伤
    2020-12-21 19:07

    You can store the value in a hidden field inside your form and so when the form is submitted the value will be sent to Action.

    ... .....

    then

    function redirect(id){
    document.getElementById('myid').value = id;
    
    document.forms["AddToCart"].submit();
    }
    

提交回复
热议问题