【发布时间】:2024-12-14 04:55:02
【问题描述】:
我在 jsp 页面上有一个 java 变量和一个 javascript。
<% int max=70; %>
如何从脚本中获取变量?
var x = ???
我尝试了 document.getElementById() 但不幸的是它似乎不起作用,因为它不是 html 元素
这是我的错误:
无法为 JSP 编译类:
An error occurred at line: 13 in the jsp file: /search.jsp
max cannot be resolved
10: function validateForm() {
11: var x=document.forms["search"]["capacity"].value;
12: var y=document.forms["search"]["date"].value;
13: var m=<%=max%>;
14: if (isNaN(x)) {
15: alert("Capacity must be an Integer");
16: return false;
【问题讨论】:
标签: java javascript jsp variables