Hi I'm trying to make a simple zodiac webpage that grabs the answer from an array using a function that has a for loop and an if statement, but the answer when I click the button continues to just flash and disappear. How do I keep the answer on the page? Here's the HTML:
<div class="header"><h1 class="zodiactitle">Learn your Life's Mysteries w/ the </br>ZODIAC</h1></div>
<form>
<input id="zodiac" placeholder=" ENTER YOUR ZODIAC">
<span class="click"><button class="button" onclick="getZodiac()">Click to find out more</button></span>
</form>
<div class="details">
<h3 id="birthdate"></h3>
<h3 id="zodiacsign"></h3>
</div>
Here's the function:
function getZodiac(){
var sign = document.getElementById("zodiac").value;
for( i = 0; i < zodiacSigns.length; i++){
//if statement to match correct input to correct zodiac
if(sign == zodiacSigns[i].sign){
document.getElementById("birthdate").innerHTML = zodiacSigns[i].birthdate;
document.getElementById("zodiacsign").innerHTML = zodiacSigns[i].zodiac;
return;
}
}
}