- 最後登錄
- 2022-10-22
- 在線時間
- 0 小時
- 註冊時間
- 2011-10-13
- 閱讀權限
- 30
- 精華
- 0
- UID
- 10420414
- 帖子
- 663
- 積分
- 1128 點
- 潛水值
- 20810 米
| 回覆中加入附件並不會使你增加積分,請使用主題方式發佈附件。 本帖最後由 theloserbm 於 2016-12-29 12:17 PM 編輯
一定要用JS嗎? 還是不用也可以?
不用的話就這樣
page1:
- <form name="form1" id="form1" method="post" action="test.php">
- <label for="textfield">name:</label>
- <input type="text" name="acc" id="textfield">
- <button type="submit">submit</button>
- </form>
複製代碼
test.php:
- echo "success! name="+$_POST['acc'];
複製代碼
要用JS的話
page1:
- <form name="form1" id="form1" method="post" action="test.php">
- <label for="textfield">name:</label>
- <input type="text" name="acc" id="textfield">
- <button type="button" onclick="fun_2()">submit</button>
- </form>
- <script>
- function fun_2(){
- document.getElementById("form1").submit();
- }
- </script>
複製代碼
test.php:
- echo "success! name="+$_POST['acc'];
複製代碼
... |
|