我的代码:
<html> <body>
<p>When you submit the form, a function is triggered which alerts sometext.</p>
<form id="abc" action="https://www.w3schools.com/action_page.php"
onsubmit="myFunction()"> Enter name: <input type="text"
name="fname"> <input type="submit" value="Submit"> </form>
<script> function myFunction() {
alert("The form was submitted"); } </script>
</body> </html>
运行正常,但我希望在提交后会显示更改表单ID,不要提醒,它会显示文字&#34;谢谢你&#34;像图片:result
我的jsfiddle:https://jsfiddle.net/nguoicovan/adpjq8bc/
答案 0 :(得分:1)
使用Ajax Jquery
<html> <body>
<p>When you submit the form, a function is triggered which alerts sometext.</p>
<form id="abc" action="https://www.w3schools.com/action_page.php"
onsubmit="myFunction()"> Enter name: <input type="text"
name="fname"> <input type="submit" value="Submit"> </form>
<script> function myFunction() {
alert("The form was submitted"); } </script>
</body>
<script> $("#abc").submit(function(e){
e.preventDefault();
$.get("https://www.w3schools.com/action_page.php",$("#abc").serialize(),function(data){alert("Thank you for submitting ")})
})</script> </html>
在使用之前不要忘记包含jquery
答案 1 :(得分:0)
您可以将“操作”更改为感谢页面
<form action="thankyou.php">
因此,当您触发提交按钮时,它将转到thankyou.php,您也可以在该页面上执行后端功能。
答案 2 :(得分:0)
for (int i = 0; i < keyList.Count; i++)
{
foreach (Range range in doc.Words)
{
if (keyList[i].Contains(range.Text.Trim()))
{
range.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkYellow;
}
}
}