I need to show a div after receiving info from a form. I got a good code to show the div after submitting the code, but for this code work, I need to use return false
so the page doesn't reload.
Here is the code:
function showHide() {
document.getElementById("hidden").style.display = "block";
}
#hidden {
display: none;
}
<html>
<body>
<form action="" method="post" class="generator-form" onsubmit="showHide(); return false">
<label for="name">
<input type="text" name="nome" placeholder="Insira seu nome" required>
</label>
<input type="submit" value="go">
<div id="hidden">hello</div>
</body>
</html>
PS: I don't know why the js is not working in here, in codepen it's.
So, here's the thing:
- I can't use
return: false
because I do need to return these values; and - I don't want to use
onclick()
because when the user clicks on the button it'll show a blank box.
To explain better, I'll get the infos I got in the form and show them in the previously hidden div. It's a signature generator for email.
There's someway I can do this with javascript or php?
</div>