jsp中如何调用function

娇烟火 2011-11-28 06:18:33
这段代码在dreamweaver中能出效果,可是在jsp中就不行了,为什么呀?
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'MyJsp.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="../css/left_css.css" rel="stylesheet" type="text/css">

<script type="text/javascript">
function showsubmenu(sid) {
whichEl = eval("submenu" + sid);
if (whichEl.style.display == "none") {
eval("submenu" + sid + ".style.display=\"\";");
} else {
eval("submenu" + sid + ".style.display=\"none\";");
}
}
</script>
</head>
<body>

<table border="1" id="table1">
<tbody id="tbody1">
<tr id="tittle">
<td>
信息编号
</td>
<td>
主题
</td>
<td>
内容
</td>
<td>
时间
</td>
<td>
留言人
</td>
<td></td>
</tr>
<c:forEach var="m" items="${requestScope.list}">

<tr id=${m.message_id }>
<td>
${m.message_id }
</td>
<td>
${m.message_subject }
</td>
<td>
${m.message_text }
</td>
<td>
${m.publish_time }
</td>
<td>
${m.name }
</td>
<td><input type="button" value="回复" onclick="javascript:showsubmenu(2)" /></td>
</tr>
<tr id=${m.message_id }>
<td>

</td>
<td colspan="2">
<table id="table2">
<tbody id="tbody2">
<tr>
<td>
<input type="text" name="admin_text" id="admin_text" />
<input type="submit" name="submit" id="submit" value="提交" />
</td>
</tr>
</tbody>
</table>
</td>

</tr>
</c:forEach>
</tbody>
</table>


</body>
</html>
...全文
797 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
默默不得鱼 2011-11-28
  • 打赏
  • 举报
回复
都木有看到有submenu
MuBeiBei 2011-11-28
  • 打赏
  • 举报
回复
<script type="text/javascript">
function showsubmenu(sid) {
whichEl = "submenu" + sid;
if (document.getElementById(whichEl).style.display == "none") {
document.getElementById(whichEl).style.display = "block";
} else {
document.getElementById(whichEl).style.display = "none";
}
}
</script>


js改成这样试试~·
p2227 2011-11-28
  • 打赏
  • 举报
回复
估计是html上有多个相同id的元素导致执行错误
默默不得鱼 2011-11-28
  • 打赏
  • 举报
回复
不知道LZ想要什么效果?

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧