将变量值从javascript传递给JSP [英] Passing a variable value from javascript to JSP

查看:97
本文介绍了将变量值从javascript传递给JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况

<select name="dropdown_Source" onchange="call()">
    <% for (int i=0 ; i < a1.length; i++) { if (a1[i]==n ull) break; %>
        <option value="<%=a1[i]%>">
            <%=a1[i]%>
        </option>
    <% } %>
</select>

<script>
    function call() {
        var source = document.forms[0].dropdown_source.value;
        // Now this 'source' value i have to pass to jsp function 
        <%
            Admin a = new Admin(); //this is class defined
            a.getResult(source); //but source is not resolved here
        %>
    }
</script>

我应该如何传入此来源值JSP功能?
a.getResult() - 函数将返回下拉元素列表,并列出
我必须填入另一个 < option> tag。

How this source value should I pass in JSP function? a.getResult() - function will return me list of dropdown elements and that list I have to populate in another <option> tag.

推荐答案

你不能这样做。在JSP页面编译完成后,JavaScript在客户端执行,并以 response 的形式发送到浏览器。

You cannot do that. JavaScript executes on the client side after JSP page is already compiled and sent to the browser as response.

这篇关于将变量值从javascript传递给JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆