Page has a text box, click Enter to submit the page

2010-08-12  来源:本站原创  分类:Web  人气:217 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<base target="_self">
<title> Location of goods  </title>
<link rel="stylesheet" href="jsp/resource/css/cjpm.css">
<script type="text/javascript">
   function tab()
                {
                if(event.keyCode==13)
                {event.keyCode=0;
                  document.getElementById('inp').focus();
                  var inp=document.getElementById('inp').value;
                  alert(inp);
                  var sel=document.getElementById('sel');
                   sel.options[sel.options.length]=new Option(inp, inp);
                   return false;
                  }

                }
                function del(){
               var sel=document.getElementById('sel');
                   sel.options.remove(sel.selectedIndex);
        }
</script>
</head>
<body  onkeydown= "if(event.keyCode==13) event.keyCode=0;return   false;"  background="jsp/resource/image/bg.gif">
<form methed="get" action="nihao...">
                        <table border=0 cellspacing=0 cellpadding=2 width="100%"
                                bgcolor="gray">
                                <tr>
                                        <td>

                                                 Location of goods
                                        </td>
                                        <td>
                                                <p align="right">&nbsp;</p>
                                  </td>
                                </tr>
                        </table>
                        <table border=0 cellspacing=0 cellpadding=2 width="100%" height="5">
                                <tr>

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

                        <table border=0 cellspacing=1 cellpadding=2 width="46%">
                                <tr>
                                        <td width="15%" align="right"><input name="textfield" type="text" size="30" onKeyDown="tab()" tabindex="1" ></td>
                                        <td></td>
                                </tr>
                                <tr>

                                  <td align="right"><select name="select" multiple="multiple"  tabindex="2" ondblclick="del()">
                                  <option value="qqq">asda444</option>
                                    </select>                               </td>
                                  <td align="right">&nbsp;</td>
                          </tr>
                        </table>

<!-- Page number information display   end-->
</form>

</body>
</html>

  Add   if(event.keyCode==13)
                  {
                  window.event.returnValue= false;
相关文章