jsp页面双击触发js事件,js取值报缺少对象,下面把代码贴出:
<script>
function getaboatinfo(id){;
var time = new Date();
var boatid = document.getElementById(id).value;
var url = "query/boatinfodwr.jsp?time="+time;
window.showModelessDialog(url,boatid,'dialogWidth:1000px;dialogHeight:500px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
}
function enterinfo(bid){
var time = new Date();
var boatid = document.getElementById(bid).value;
var url = "query/bscoremx.jsp?time="+time;
window.showModelessDialog(url,boatid,'dialogWidth:1000px;dialogHeight:500px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
}
</script>
HTML CODE:
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_style">
<tr >
<td width="15%" class="left_title_1"><span class="left-title">名称</span></td>
<td width="15%" class="left_title_1"><span class="left-title">英文名称</span></td>
<td width="15%" class="left_title_1"><span class="left-title">IMO</span></td>
<td width="20%" class="left_title_1"><span class="left-title">船籍港</span></td>
<td width="10%" class="left_title_1"><span class="left-title">风险等级</span></td>
<td width="15%" class="left_title_1"><span class="left-title">管理</span></td>
</tr>
<%
for(int i=0;i<l.size();i++ ){
Boatscore s = (Boatscore)l.get(i);
Boatinfo binfo = s.getBoatinfo();
System.out.println("--boat_p_m--1011--"+binfo.getBoatid());
%>
<tr style="cursor:pointer;" >
<td class="left_content_2" ><a href="#" ondblclick="getaboatinfo('boatid+<%=i+1 %>')">
<%=binfo.getBoatchinaname() %></a></td>
<td class="left_content_2" ><%=binfo.getBoatenglishname() %></td>
<td class="left_content_2"><%=binfo.getImonumber() %><input type="hidden" id="'boatid'+<%=i+1 %>" name="'boatid'+<%=i+1 %>" value="<%=binfo.getBoatid() %>"/></td>
<td class="left_content_2"><%=binfo.getRegistport() %></td>
<td class="left_content_red"><a href="#" ondblclick="enterinfo('boatid+<%=i+1 %>')"><span class="left_content_red">
<%=s.getScore() %></span></a></td>
<td class="left_content_2"><input type="button" value="查看*****信息" onclick="getbadofboat('scoreid+<%=i+1 %>')"/></td>
</tr>
<%
}
%>
</table>"var boatid = document.getElementById(bid).value;"js中的两个function都是这句报缺少对象,之前getaboatinfo(id)能正常运行。请高手指点....先谢过....
<script>
function getaboatinfo(id){;
var time = new Date();
var boatid = document.getElementById(id).value;
var url = "query/boatinfodwr.jsp?time="+time;
window.showModelessDialog(url,boatid,'dialogWidth:1000px;dialogHeight:500px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
}
function enterinfo(bid){
var time = new Date();
var boatid = document.getElementById(bid).value;
var url = "query/bscoremx.jsp?time="+time;
window.showModelessDialog(url,boatid,'dialogWidth:1000px;dialogHeight:500px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
}
</script>
HTML CODE:
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" class="table_style">
<tr >
<td width="15%" class="left_title_1"><span class="left-title">名称</span></td>
<td width="15%" class="left_title_1"><span class="left-title">英文名称</span></td>
<td width="15%" class="left_title_1"><span class="left-title">IMO</span></td>
<td width="20%" class="left_title_1"><span class="left-title">船籍港</span></td>
<td width="10%" class="left_title_1"><span class="left-title">风险等级</span></td>
<td width="15%" class="left_title_1"><span class="left-title">管理</span></td>
</tr>
<%
for(int i=0;i<l.size();i++ ){
Boatscore s = (Boatscore)l.get(i);
Boatinfo binfo = s.getBoatinfo();
System.out.println("--boat_p_m--1011--"+binfo.getBoatid());
%>
<tr style="cursor:pointer;" >
<td class="left_content_2" ><a href="#" ondblclick="getaboatinfo('boatid+<%=i+1 %>')">
<%=binfo.getBoatchinaname() %></a></td>
<td class="left_content_2" ><%=binfo.getBoatenglishname() %></td>
<td class="left_content_2"><%=binfo.getImonumber() %><input type="hidden" id="'boatid'+<%=i+1 %>" name="'boatid'+<%=i+1 %>" value="<%=binfo.getBoatid() %>"/></td>
<td class="left_content_2"><%=binfo.getRegistport() %></td>
<td class="left_content_red"><a href="#" ondblclick="enterinfo('boatid+<%=i+1 %>')"><span class="left_content_red">
<%=s.getScore() %></span></a></td>
<td class="left_content_2"><input type="button" value="查看*****信息" onclick="getbadofboat('scoreid+<%=i+1 %>')"/></td>
</tr>
<%
}
%>
</table>"var boatid = document.getElementById(bid).value;"js中的两个function都是这句报缺少对象,之前getaboatinfo(id)能正常运行。请高手指点....先谢过....
这样定义是错误的
写
id="boatid<%=i+1 %>"