日期:2014-05-16  浏览次数:20300 次

关于 onkeydowm 事件触发任务
JScript code
 function enterSumbit(hotarea,typeFlag){   
      var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异   
     if (event.keyCode == 13){   
      classidcheck(hotarea,typeFlag);
     }   
 }  
function classidcheck(hotarea,typeFlag)
{
 var pname = document.getElementById("name").value;
 var cstr = document.getElementById("classstr").value;
 window.location.href="/system/hot/add_hot_ticket2.jsp?hotarea="+hotarea+"&typeFlag="+typeFlag+"&name="+pname+"&classstr="+cstr;
  [color=#FF0000]alert("ok");[/color]}


HTML code

按商品名称查询:<input name="name" class="text-line" value=""  onkeydown="enterSumbit('<%=hotarea%>','<%=typeFlag%>')" />



为什么一定要 alert(“OK”) 回车后它才执行?
多谢!

------解决方案--------------------
你把alert("ok")换成return false试试
------解决方案--------------------
document.getElementById("name") //应该传入id值,而不是name
HTML code
<input id="hotarea" name="name" class="text-line" value=""  onkeydown="enterSumbit('<%=hotarea%>','<%=typeFlag%>')" />

document.getElementById("hotarea").value