简体   繁体   中英

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. 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 .

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.

 <form onsubmit="sayThanks()">

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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