Why is the text flashing but not staying put?

<style>html {background: #171717}</style>
<p style="color: white;" >
Enter message:
<input type="text" title="Enter message..." id="comment">
<input type="submit" title="Send message" onclick="post()">
<div id="mess" style="color: white;">
message = document.getElementById("comment");
function post() {

When I run that it flashes the text on submit instead of putting it in for good, can anyone tell me why this happens? Everything works fine, and if I were to have it be an alert instead of inserting it into the html it works fine.

It’s because the button has the “submit” type, which actually changes the URL and causes the page to reload. You can just change the type to “button”.

*changes the URL if you used POST to pass variables, but the page will reload regardless.

1 Like

These tags are in the wrong place - they should come after the </style> tag

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.