开发者

How to compare javascript variable with Jsp variable?

开发者 https://www.devze.com 2023-03-17 15:12 出处:网络
I want to compare a javascript variable with a jsp variable. How can I do this? function verify_details()

I want to compare a javascript variable with a jsp variable. How can I do this?

 function verify_details()
   {
    var resourceId=document.getElementById("res").value;'
    <%! String rId;%>
    <%
    for(int i=0;i<l.size();i++)
    {
      rId=l.get(i).toString开发者_Python百科();
       System.out.println("Elements Are:"+rid);
    %>
       if(resourceId==rId)
        alert("Alloted");
       else
           alert("Not Alloted");  

   <%}%>

   }


You shouldn't be doing this in the first place. See this.

If you really want to, make a new JSP with this code in it, pass the variable you want to compare as a parameter (call that page with AJAX) and get the result.

But, that's overly complicated and this situation should really never occur in code that is well structured.


Use some control like 'hidden' or any other. Its value will be accessible in both javascript and jsp.

0

精彩评论

暂无评论...
验证码 换一张
取 消