我正在处理联系人页脚。 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) –