双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

如何把java的数组的值给javascript?

qq1299338446 qq1299338446 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<%@ page language="java" contentType="text/html; charset=GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>search result</title>
</head>
<body background= "<%=request.getContextPath()%>/img/top1.jpg">
<%
int i;
String [] toJsp=(String [])request.getAttribute("toJsp");//这里是从action获得的内容
System.out.println(toJsp.length);
%>
<%int count=0;%>
<center>
<form name="form1">
<table align="center">
<tr align="center"><td><input type="button" value="新增" onClick="newadd()"/></td><td><input type="button" value="查看" onClick="check()"/></td><td><input type="button" value="修改" onClick="update()" /></td></tr>
<tr align="center"><td align="center">选择</td><td align="center">题目</td><td align="center">日期</td></tr>
<% for(i = 0;i < toJsp.length;){ %>
<tr align="center"><td><input type="checkbox" value="查看" id="CheckBox<%=i%>"></td><td><%=toJsp[i] %></td><td><%=toJsp[++i]%></td><%i=i+2; %>
<%} %>
</table>
<table align="center">
<tr align="center"><td>内容</td></tr>
<tr align="center"><td><input type="text" id="text1"></td></tr>
<tr align="center"><td><textarea cols="40" rows="10" id="text2"></textarea></td></tr>
</table>
</form>
</center>
</body>

<script type="text/javascript" language="javascript">
function check()
{
var j=0;

while(j<<%=toJsp.length%>)
{<%System.out.println("JAVA001"+count);%>
if(document.getElementById("CheckBox".concat(j)).checked)
{alert(j);alert("count上面="+<%=count%>);
document.getElementById("text1").value = <%=toJsp[count]%>;//就是这边count会变成0
document.getElementById("text2").value = <%=toJsp[count+2]%>;

<%count=0;%>
break;
}
else
{
j = j+3;alert(j);
<%count = count +3; System.out.println("JAVA"+count);%>
alert("count下面="+<%=count%>);
}

}
}

function newadd()
{
document.form1.action = "<%=request.getContextPath()%>/frame/newStudy.jsp";
document.form1.submit();
}


function data(x,y)
{ alert("a");
document.getElementById("text1").value = x;
document.getElementById("text2").value = y;
}



function update()
{
document.form1.action = "<%=request.getContextPath()%>/frame/update.jsp";
document.form1.submit();
}

</script>
</html>
...全文
评论 10
收藏 已收藏
分享
返回顶部
qq1299338446
Java EE 67,535 成员 225,843 内容