按钮触发javascript有问题,一直没反应,请高手看看

xuhuiqiang 2008-07-25 09:59:42
源代码是这样的:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="com.xhq.rfid.*"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:12px;
top:152px;
width:64px;
height:22px;
z-index:1;
background-image: url(image/939.gif);
visibility: hidden;
}
#Layer2 {
position:absolute;
left:180px;
top:195px;
width:64px;
height:22px;
z-index:2;
background-image: url(image/937.gif);
visibility: hidden;
}
#Layer3 {
position:absolute;
left:180px;
top:155px;
width:63px;
height:23px;
z-index:3;
background-image: url(image/938.gif);
visibility: hidden;
}
#Layer4 {
position:absolute;
left:180px;
top:105px;
width:63px;
height:24px;
z-index:4;
background-image: url(image/940.gif);
visibility: hidden;
}
#Layer5 {
position:absolute;
left:180px;
top:238px;
width:63px;
height:24px;
z-index:5;
background-image: url(image/936.gif);
visibility: hidden;
}
#Layer6 {
position:absolute;
left:12px;
top:103px;
width:62px;
height:24px;
z-index:6;
background-image: url(image/941.gif);
visibility: hidden;
}
#Layer7 {
position:absolute;
left:115px;
top:16px;
width:23px;
height:59px;
z-index:7;
background-image: url(image/942.gif);
visibility: hidden;
}
#Layer8 {
position:absolute;
left:163px;
top:16px;
width:25px;
height:57px;
z-index:8;
background-image: url(image/943.gif);
visibility: hidden;
}
#Layer9 {
position:absolute;
left:218px;
top:16px;
width:24px;
height:58px;
z-index:9;
background-image: url(image/944.gif);
visibility: hidden;
}
#Layer10 {
position:absolute;
left:292px;
top:16px;
width:24px;
height:57px;
z-index:10;
background-image: url(image/945.gif);
visibility: hidden;
}
#Layer11 {
position:absolute;
left:326px;
top:16px;
width:25px;
height:58px;
z-index:11;
background-image: url(image/946.gif);
visibility: hidden;
}
#Layer12 {
position:absolute;
left:380px;
top:16px;
width:24px;
height:58px;
z-index:12;
background-image: url(image/947.gif);
visibility: hidden;
}
#Layer13 {
position:absolute;
left:415px;
top:16px;
width:25px;
height:57px;
z-index:13;
background-image: url(image/948.gif);
visibility: hidden;
}
#Layer14 {
position:absolute;
left:459px;
top:103px;
width:30px;
height:64px;
z-index:14;
background-image: url(image/949.gif);
visibility: hidden;
}
#Layer15 {
position:absolute;
left:461px;
top:16px;
width:25px;
height:58px;
z-index:15;
background-image: url(image/950.gif);
visibility: hidden;
}
#Layer16 {
position:absolute;
left:426px;
top:100px;
width:24px;
height:24px;
z-index:16;
background-image: url(image/heart.gif);
visibility: hidden;
}
-->
</style>

<%
tool tooler1=new tool();
String left=null;
String top=null;
String rea=request.getParameter("readernum1");
String ant=request.getParameter("antennanum1");
String result=null;
if(rea!=null&&ant!=null)
result=tooler1.findroom(rea,ant);
String[] position=new String[2];
if(result!=null)
{
position=tooler1.checkposition(result);
left=position[0];
top=position[1];
}
%>
<script language="javascript">



var i=0;
function hide(sid)
{
var k;
var j;
for(k=1;k<=sid;k++)
{
j=document.getElementById("Layer"+k);
var obleft=j.offsetLeft;
var obtop=j.offsetTop;

if(j!=null&&j.offsetParent!=null)
{
obleft+= j.offsetParent.offsetLeft;
obtop+= j.offsetParent.offsetTop;
}
j.style.display='none';
}
}

function display(left,top)
{
alert("test");
var j=document.getElementById("Layer16");
j.offsetLeft=left;
j.offsetTop=top;
document.getElementById("Layer16").style.display='block';
for(var p=0;p<100;p++)
setTimeout('display(left,top)',5);
document.getElementById("Layer16").style.display='none';
}

function move()
{
i++;
if(i<200)
{
setTimeout('move()',5);
}
else
document.getElementById("Layer1").style.display='none';
}
</script>

</head>

<body >

<div id="Layer1"></div>
<div id="Layer2"></div>
<div id="Layer3"></div>
<div id="Layer4"></div>
<div id="Layer5"></div>
<div id="Layer6"></div>
<div id="Layer7"></div>
<div id="Layer8"></div>
<div id="Layer9"></div>
<div id="Layer10"></div>
<div id="Layer11"></div>
<div id="Layer12"></div>
<div id="Layer13"></div>
<div id="Layer14"></div>
<div id="Layer15"></div>
<div id="Layer16"></div>
<form action="" method="get" name="form1">
<table width="100%" height="250" border="0" cellspacing="1" bordercolor="#000000">
<tr>
<td width="600" height="250" background="image/see.jpg"> </td>
<td ><table width="100%" height="250" border="0" cellspacing="0">
<tr>
<td height="250" width="50%"> </td>
<td height="250"><table width="100%" height="250" border="2" cellspacing="0" bordercolor="#000000">
<tr>
<td height="100%"><table width="100%" height="100%" border="1" cellspacing="2">
<tr height="50%">
<td height="125" > </td>
</tr>
<tr height="50%">
<td height="125" ><form action="" method="get" name="changeroom" target="_parent" >
<table width="100%" border="0" cellspacing="0">
<tr>
<td><div >
Reader:
<input name="readernum1" type="text" id="reader" size="5" />
</div></td>
</tr>
<tr>
<td><div >
Antenna:
<input name="antennanum1" type="text" id="reader" size="5" />
</div> </td>
</tr>
<tr>
<td>
<div >
<input name="提交" type="submit" value="查找房间" onclick="display(position[0],position[1])"/>
Room:
<input name="roomnum1" type="text" id="reader" size="5" value="<%=result%>"/>

</div></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>

</table></td>
</tr>
</table>

</form>
</body>
</html>
但是后面的那个提交按钮一直没法触发!!!
...全文
173 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovingprince 2008-07-25
  • 打赏
  • 举报
回复
<input name="提交" type="submit" value="查找房间" onclick="display(position[0],position[1])"/> 是有Js错误的,你的position是JSP服务器的方法,而你调用的是JS的方法,当然会出错了。
<input name="提交" type="submit" value="查找房间" onclick="display(<%=position[0]%>,<%=position[1])%>"/> 应该没问题,你看看好了,我随便写的,只是提示你错误在这里。

81,092

社区成员

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

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