简体   繁体   English

js提交没有价值

[英]js submit without value

When I submit the form with JS. 当我用JS提交表单时。 No value can be found. 找不到值。
This is my Code: 这是我的代码:

<!-- Form file --> 

<form id="postnotes" name="postnotes" action="./mechanic/comments.php" method="post">
    <textarea id="comments" class="comments" rows="4" name="comment" cols="50" placeholder="Make a note"></textarea>
</form>

<script type="text/javascript">
$(function() {
 $('textarea#comments').on('keyup', function(e) {
   if (e.which == 27 && ! e.shiftKey) {

        document.getElementById("postnotes").submit();
       }
   });
  });
 </script>
 <!-- file comments -->
 <?php if(isset($_POST['postnotes'])){
  echo 'hello its me your looking for';

 }
  else{echo 'nope srry';}

 ?>

Can somebody please help me. 有人能帮帮我吗。
Thanks in advance! 提前致谢!

The submit is fine, although it seems odd to submit when the user presses Esc . 提交很好,尽管当用户按下Esc时提交似乎很奇怪。 It's the PHP checking for a submission that's incorrect. 这是PHP检查提交不正确的内容。 You're looking for a field using the name of the form ( postnames ). 您正在使用表单名称( postnames )寻找一个字段。 It's the name of the field that gets sent ( comment , the name of the textarea ), eg look in $_POST["comment"] , not $_POST["postnames"] . 这是要发送的字段的名称( commenttextareaname ),例如,查看$_POST["comment"]而不是$_POST["postnames"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM