我正在處理聯繫人頁腳。 HTML看起來像這樣:同時運行Javascript函數和PHP
<form action="indexTest.php" method="post">
<input spellcheck="false" class="first" type="text" name="name" placeholder="name">
<input spellcheck="false" class="first" type="text" name="email" placeholder="email">
<textarea rows="5" spellcheck="false" class="last" type="text" name="message" placeholder="message"></textarea>
<input type="submit" name="submit" value="" id="button" onclick="banner()">
</form>
現在,如果我點擊「提交」,PHP文件正在運行。但是正如你在代碼中看到的那樣,你會看到「onclick =」banner()「,但這是行不通的,只有PHP的工作原理,它想運行Javascript函數和PHP。要做到這一點,如果你點擊「提交」;在PHP文件運行和橫幅被使用Javascript顯示
[Ajax](https://en.wikipedia.org/wiki/Ajax_(programming))。 – 3ocene
當你提交表單時,它會將你重定向到indexTest.php,你的旗幟將會消失。你如何期待它同時做到這一點? – mpen
[使用Ajax的表單示例](http://codegarycode.com/post.php?title=Submitting+an+HTML+form+via+Ajax) –