81,094
社区成员
发帖
与我相关
我的任务
分享
<%@ page contentType="text/html; charset=UTF-8" %>
<html>
<head>
<title>
jsp2
</title>
</head>
<%
String d_id = "测试数据";
%>
<body onload="getdid_2('<%=d_id%>')">//在页面加载的时候调用getdid_2()方法 把d_id传进去
<input type="hidden" name="d_id" value="<%=d_id%>"/>//把值放入隐藏域中
<input type="button" name="hq" value="点这获得值" onclick="getdid()"/>//点击调用getdid()方法
</body>
</html>
<script type="text/javascript">
function getdid()
{
var d_id = document.getElementById("d_id").value;
alert("d_id的值是:"+d_id);
}
function getdid_2(str)
{
alert("d_id的值是:"+str);
}
</script>
function getdid()
{
var d_id = document.getElementById("partName").value;
document.getElementById("hid").value = d_id; // 可以将值放到隐藏域中
}
<input type="hidden" name="hid" id="hid">
String str_val = request.getParemeter("hid");