简体   繁体   English

更改表单内容以感谢您的消息

[英]change form content to thank you message

So I've been looking around a lot of different ways to get a thank you message when answering a form, and realised that there are plenty of ways.所以我一直在寻找很多不同的方式来回答表单时收到感谢信息,并意识到有很多方法。

However, I just want to change the content in a div box (where the form is) to a thank you message after one has clicked the submit button, and submitted the form, without refreshing the page or redirecting to another.但是,我只想在单击提交按钮并提交表单后将 div 框中(表单所在的位置)中的内容更改为感谢消息,而无需刷新页面或重定向到另一个页面。 In other words, the form disappears, and a Thank You message appears instead.换句话说,表单消失,而是显示感谢消息。 How do I do this?我该怎么做呢?

I want it to look like on the HeforShe website .我希望它在HeforShe 网站上看起来像。

You just need to set the value after the form is submitted.您只需要在提交表单后设置该值。 You can use the onsubmit event to hook up in the form submission.您可以使用onsubmit事件来连接表单提交。

 <form onsubmit="sayThanks()">

 function sayThanks() { document.getElementById("thankYouMessageDiv").innerHTML = "Your message"; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM