1

当我更改输入字段时,我尝试自动提交表单但没有任何反应,但我可以使用“警报(消息)”显示一条消息,请你帮帮我!!!

我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
       <script type="text/javascript" src="script/jquery-1.8.3.min.js"></script>
   </head>
  <body>
       <form method="POST" id="form" action="">
           <fieldset>
              Text 1 : <input id="text1" type="text" name="text1" value="" />
              <input id="submit" type="submit" name='submit' value="Send"/>
           </fieldset>
        </form>

        <script>

             $('#form input[name=text1]').change(function(){
             $('#form').click();
             //alert("Changed!");// This works
              });
       </script>

 </body>

 </html> 
 <?php
   if (isset($_POST['submit'])){
    echo $_POST['text1'];
   }
  ?>
4

2 回答 2

1

尝试这个 -

$('#form input[name=text1]').change(function(){
    $('#form').submit();    
});

http://api.jquery.com/submit/

于 2013-04-26T21:10:54.680 回答
0

尝试:

$('#form input[name=text1]').change(function(){
    $("#submit").click();
});
于 2013-04-26T21:28:09.450 回答