我有兩個文件(file1和file2)。 file1在PHP include語句中包含file2。 File1還包含一個表單並打印出所有$ _POST變量。 File2使用Javascript按鈕來動態更改輸入字段中的值。問題是按下提交後$ _POST爲空。爲什麼是這樣,我該如何解決它?
文件1:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php include 'file2.php'; ?>
<input type="submit" /></form>
<?php foreach ($_POST as $key => $val) { echo $key . " belongs to " . $val; } ?>
文件2
<script type="text/javascript">
var button = {
counter : 0,
count : function() {
text = document.getElementById("text");
this.counter++;
text.setAttribute("value", this.counter);
}
};
</script>
<button type="button" onclick="button.count()">CLICK ME!</button>
<input id="text" type="text" value="0" />
你輸入需要一個name屬性,當它是由PHP – kjy112 2011-05-20 14:17:18