我有两个文件,(file1和file2). file1包含PHP include语句中的file2. File1还包含一个表单并打印出所有$_POST变量. File2使用Javascript按钮动态更改输入字段中的值.问题是按下提交后$_POST为空.为什么这样,我该如何解决?
文件1:
<?php foreach ($_POST as $key => $val) { echo $key . " belongs to " . $val; } ?>
文件2
var button = {
counter : 0,
count : function() {
text = document.getElementById("text");
this.counter++;
text.setAttribute("value", this.counter);
}
};
CLICK ME!
解决方法:
您忘记设置名称属性:
标签:javascript,php,forms,post
来源: https://codeday.me/bug/20190730/1578377.html