Hello, I'm facing a bit of an issue with a for loop inside an On-Click Event. It seems like the loop is only showing me the last value from the array. Can someone please lend a hand here?
Below is the code snippet where I have an array with 10 values. I've tried using both a for loop and a foreach loop, but they are giving me the same outcome:
function getArray(){<br>
for(var i=0;i<Array_Name.length;i++){<br>
document.getElementById("p2").innerHTML=Array_Name[i]; <br>
}}
<br>
<input type="submit" value="CalC" onclick="getArray()" />
My aim is to display all 10 values when the button is clicked. Any suggestions or solutions would be greatly appreciated.