居然提示是上一行的错误,“对象不支持此属性或方法”
(上一行是<td>啥的,肯定不是提示行的错)

解决方案 »

  1.   

    <body onkeydown="if((event.keyCode==13)&&event.ctrlKey) haha.submit();return true;">
    <form action="lyok.asp" name="haha" method="post" onsubmit="alert('表单已提交!');return false;">
    <textarea rows="4" name="cword" cols="49" onkeydown="if(event.ctrlKey && event.keyCode==13) document.postart.submit();"></textarea>
    <input type="submit" value="提交" name="submit">
    </form>
    </body>
    看这样可以不?
      

  2.   

    to AgathaZ:只粘你的那段代码,单存成一个htm文件,还是提示那个错误!奇怪了:(
      

  3.   

    测试通过   原因可能是<input type="submit" value="提交" name="submit">中的name<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script>
    function test(){if(window.event.keyCode==13&&window.event.ctrlKey){
    document.haha.submit();
    }
    }</script>
    </HEAD><BODY>
    <body onkeydown="test();">
    <form action="lyok.asp" name="haha" method="post" >
    <textarea rows="4" name="cword" cols="49"></textarea>
    <input type="submit" value="提交" >
    </form>
    </body></BODY>
    </HTML>
      

  4.   

    接上<input type="submit" value="提交" name="submit">中的name="submit"    影响了event.keyCode 的判断  所有出错.
      

  5.   

    谢谢longshenwang大侠,ctrl+enter可以实现表单提交了。
    可是ctrl+enter直接提交表单,并不执行checkadd()函数。(代码如下)
    如果用按钮提交,就会执行checkadd()函数进行判断。
    <form action="lyok.asp" method="post" name="postart" onsubmit="return checkadd()">
    <input type="text" name="cname">
    <textarea name="cword" onkeydown="javascript:if(event.ctrlKey && event.keyCode==13) document.postart.submit();">
    <input type="submit" value="提交">
    </form>chechadd()函数判断cname的文本框输入不为不空。
    <script language="javascript">
    <!--
    function checkadd()
    {
      if(document.postart.cname.value.length<1)
      {
      alert("请填写昵称!");
      document.postart.cname.focus();
      return false;
      }
    }
    -->
    </script>
    还需要各位大侠帮忙解决:(
      

  6.   

    调用submit()方法提交表单不触发onsubmit事件
    onkeydown="javascript:if(event.ctrlKey && event.keyCode==13&&checkadd())document.postart.submit();"
      

  7.   

    改为 就可以了<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script>
    function test(){if(window.event.keyCode==13&&window.event.ctrlKey){
    if(checkadd()){
      document.haha.submit();
    }
    }
    }
    function checkadd()
    {
      if(document.haha.cword.value.length<1)
      {
      alert("请填写昵称!");
      document.haha.cword.focus();
      return false;
      }
    }</script>
    </HEAD><BODY>
    <body onkeydown="test();">
    <form action="lyok.asp" name="haha" method="post" onsubmit="return checkadd();">
    <textarea rows="4" name="cword" cols="49"></textarea>
    <input type="submit" value="提交" >
    </form>
    </body></BODY>
    </HTML>
      

  8.   

    问题还真是多:(又有新问题出现:
    牛人的办法解决了ctrl+enter提交时执行checkadd()判断,可是它提示两遍“请填写昵称!”
    当在canme填写好昵称后,按ctrl+enter键提交没反应了……,这会应该是正确提交不是么?为什么却没反应?
      

  9.   

    这回好了 呵呵  忽略了 那个enter 是 文本域 不为空了...<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <script>
    function test(){if(window.event.keyCode==13&&window.event.ctrlKey){
    if(checkadd()){
      document.haha.submit();
    }else{
        document.haha.cword.focus();
        window.event.keyCode=8;
    }
    }
    }
    function checkadd()
    {
      if(document.haha.cword.value.length==0)
      {
      alert("请填写昵称!");
      document.haha.cword.focus();
      document.haha.cword.value="";
      return false;
      }else{
      return true;
      }
    }</script>
    </HEAD><BODY>
    <body onkeydown="test();">
    <form action="lyok.asp" name="haha" method="post" onsubmit="return checkadd();">
    <textarea rows="4" name="cword" cols="49"></textarea>
    <input type="submit" value="提交" >
    </form>
    </body></BODY>
    </HTML>
      

  10.   

    555……还是不对。
    cname和cmail框判断了,也响应ctrl enter事件
    可是到了cword框就不响应了。怪了,怎么这么怪?
    请问window.event.keyCode=8;
    这句代码是什么作用?
      

  11.   

    window.event.keyCode=8;相当于按下退格键。不过纯属卖弄(个人认为)。用document.haha.cword.value=""清空文本框。
    if(document.haha.cword.value.length==0)
    =〉
    if(document.haha.cword.value=="")
      

  12.   

    to  --- xinyunyishui(心云意水) 大哥 !!!!  我那里是卖弄啊  是ctrl+enter  的时候  如果为内容空文本域重新得到焦点 但是光标的位置由于ctrl+enter操作(中有一个enter)而到了下一行啦...... 所以想退回去!使用 document.haha.cword.value=""  右不行  啊  有没有更好的方法??
      

  13.   

    /*******************js的代码如下:***************************/<script language="javascript">
    <!--
    function checkadd()
    {
      if(document.postart.cname.value.length<1)
      {
      alert("请填写昵称!");
      document.postart.cname.focus();
      return false;
      }  
      if(document.postart.cmail.value.length<1)
      {
      alert("请填写电子邮箱!");
      document.postart.cmail.focus();
      return false;
      }
      
      
        if ( (document.postart.cmail.value).search("@")== -1 )
    {
       alert("请正确填写邮箱地址!");
       document.postart.cmail.focus();
           return false;
    }
        
       if(document.postart.cword.value.length<1)
       {
       alert("请填写留言内容!");
       document.postart.cword.focus();
       return false;
       }
        
      if(document.postart.cword.value.length>100)
      {
      alert("留言内容应少于100字!");
      document.postart.cword.focus();
      return false;
      }
    }function test(){
    if(window.event.keyCode==13&&window.event.ctrlKey){
        if(checkadd()){
            document.postart.submit();
        }else{
        window.event.keyCode=8;
       }
    }
    }
    -->
    </script>
      

  14.   

    /********************************************/
    <body onkeydown="test();">
    <form action="lyok.asp" method="post" name="postart" onsubmit="return checkadd()">
    <input type="text" name="cname" size="30" maxlength="50" style="border: 1 solid #000000">
    <input type="text" name="cmail" size="30" maxlength="50" style="border: 1 solid #000000">
    <textarea rows="4" name="cword" cols="49" style="border: 1 solid #000000" title="可以使用Ctrl+Enter直接提交"></textarea>
    <input type="submit" value="提交">
    <input type="reset" value="取消" name="reset"></form>
    </body>
    各位大侠真是好人,本人感动得痛哭流涕:)
    其他代码就是有关asp的了,应该不是asp的错误吧:(
      

  15.   

    哎~~~
    function test(){
    if(window.event.keyCode==13&&window.event.ctrlKey){
    if(checkadd())//注意这个地方!!!!!!!!!!!!!!
    {
      document.haha.submit();
    }
    }
    }
    function checkadd()
    {
      if(document.haha.cword.value.length<1)
      {
      alert("请填写昵称!");
      document.haha.cword.focus();
      return false;
      }
    //看看这个地方!!!!!!!!!!!
    }
    看出来了吗???
    如果满足提交条件function checkadd()并没有返回值!当然test()不会有什么动作啦!
    在function checkadd()我的注释前边的地方写:return true;
      

  16.   

    你看我写的代码中的函数function checkadd()
    {
      if(document.haha.cword.value.length==0)
      {
      alert("请填写昵称!");
      document.haha.cword.focus();
      document.haha.cword.value="";
      return false;
      }else{
      return true;   ////这里 需要写的!
      }
    }