首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

一个js脚本的有关问题

2012-03-22 
一个js脚本的问题htmlheadtitle 加中科技医院信息系统 /titlelinkrel stylesheet href inc/

一个js脚本的问题
<html>
<head>
<title> 加中科技医院信息系统 </title>
<link   rel= "stylesheet "   href= "inc/style.css "   type= "text/css ">
<script   language= "javascript "   src= "inc/select_date.js "   charset= "utf-8 "> </script>
<script   type= "text/javascript ">
var   str=0;
function   getdate(temp)
{
for(m=1;m <document.all.table1.rows.length;m++)
{
var   str=document.all.table1.rows[m];
for(n=0;n <str.cells.length;n++)
{
str.cells[n].className= "row ";
}
}
for(i=0;i <temp.cells.length;i++)
{
temp.cells[i].className= "clickchoose ";
str=temp.rowIndex;
alert(str);
}
parent.window.frames[ "aa "].location.href= "yClinicReckQueryFindOne.do?rcptNo= "+temp.cells[0].innerHTML;
parent.window.frames[ "bb "].location.href= "yClinicReckQueryFindTwo.do?rcptNo= "+temp.cells[0].innerHTML;
}

function   keydownPlus() <%--处理快捷键。ywang1230--%>
{
if(window.event.keyCode==40)
{
str++;
alert( "keydown "+str);
if(str <document.all.table1.rows.length)
{
getdate(document.all.table1.rows[str]);
}
else
{
getdate(document.all.table1.rows[1]);
str=1;
}
}
}
document.onkeydown=keydownPlus; <%--处理快捷键。ywang1230--%>
</script>
</head>
<body>
<table   align= "center "   cellpadding= "0 "   cellspacing= "1 "   class= "tableBorder "   id= "table1 "   name= "table1 "   width= "100% ">
<tr>
<td   height= "30px "   align= "center "   class= "td ">
收据号
</td>
<td   height= "30px "   align= "center "   class= "td ">
病人姓名
</td>
<td   height= "30px "   align= "center "   class= "td ">
费别
</td>
<td   height= "30px "   align= "center "   class= "td ">
应收
</td>
<td   height= "30px "   align= "center "   class= "td ">
实收
</td>
<td   height= "30px "   align= "center "   class= "td ">
交费标志
</td>
<td   height= "30px "   align= "center "   class= "td ">
退费收据号
</td>
</tr>
<logic:present   name= "list ">
<logic:iterate   id= "element "   name= "list ">
<tr   align= "center "   onclick= "getdate(this) ">
<td   class= "row "   height= "30 "> <bean:write   name= "element "   property= "rcptNo "   /> </td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "name "   />
</td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "chargeTypeName "   />


</td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "totalCosts "   />
</td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "totalCharges "   />
</td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "chargeIndicatorName "   />
</td>
<td   class= "row "   height= "30 ">
<bean:write   name= "element "   property= "refundedRcptNo "   />
</td>
</tr>
</logic:iterate>
</logic:present>
</table>
</body>
</html>

我的目的是单击table1的某一行,使这一行变颜色,temp.cells[i].className= "clickchoose ";就实现了变颜色.然后按键盘上的向下箭头键,选中该行的下一行.
现在的问题是,单击选中了之后,再按向下箭头键的话,总是从第一条开始变颜色.
好象是这样操作单击之后没有给str赋值一样,但实际上是赋值了啊.为什么一按向下的箭头,str为什么会重新刷新为0呢?
我的这个页面在另一个页面的iframe里,是不是因为这个问题啊?


[解决办法]
是不是按向下的箭头之后,页面就被刷新了啊。
把var str=0;去掉看看。
另外在js脚本中加alert看看每一步str的变化。

热点排行