I have here a working code regarding arrays but i want my input to display in new lines not a single row. I have tried \n but no luck.
Here is my code:
<html>
<meta charset="UTF-8">
<head>
<title>Sample Array</title>
<script>var index = 0;</script>
</head>
<body>
Input:
<input type="text" id="input">
<input type="button" value="GO" onClick="press(input.value)">
<p id = "display">
<script>
var sample = new Array();
function press(Number)
{
if ( Number != '' )
{
sample[index] = Number;
document.getElementById("display").innerHTML += sample[index] + "\n";
index++;
}
else
alert("empty");
}
</script>
</body>
</html>
I want to code the newline within the document.getElementById. Thanks in advance.