At this moment, the info, stat and foo elements are hidden. Strangely, when I submit the form, they don't become visible. However, if I incorporate the unhide() function within the
<button onclick="unhide()"></button>
, it works perfectly fine. But for some reason, it fails to work inside the form.
Is there a way for the unhide() function to reveal these elements after form submission?
<style>
#info {
visibility: hidden;
}
#stat {
visibility: hidden;
}
#foo {
visibility: hidden;
}
</style>
<script>
function unhide() {
var x = document.getElementById("info");
var y = document.getElementById("stat");
var z = document.getElementById("foo");
if (x.style.visibility === "hidden" && x.style.visibility === "hidden" && x.style.visibility === "hidden") {
x.style.visibility = "visible";
y.style.visibility = "visible";
z.style.visibility = "visible";
}
else{
x.style.visibility = "hidden";
y.style.visibility = "hidden";
z.style.visibility = "hidden";
}
}
</script>
<form method="GET" onsubmit="unhide()" action="../index.js" class="justify-center flex p-6">
<input class="mt-4 text-lg p-3 text-white rounded-l-md border-white border-2 bg-gray-900 outline-none" type="text" name="search" placeholder="Enter country">
<input class="mt-4 py-3 px-6 font-bold rounded-r-md text-lg cursor-pointer" value="search" id="submit" type="submit">
</form>