Cómo mostrar palabras de una matriz en un cuadro en JavaScript
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Demo of adding element to an array</title>
</head>
<body>
<script type="text/javascript">
var data = new Array(); // creating array
function add_element(){
data.push(document.getElementById('t1').value); // adding element to array
document.getElementById('t1').value=''; // Making the text box blank
disp(); // displaying the array elements
}
function disp(){
var str='';
str = 'total number of elements in data array : ' + data.length + '<br>';
for (i=0;i<data.length;i++)
{
str += i + ':'+data[i] + "<br >"; // adding each element with key number to variable
}
document.getElementById('disp').innerHTML=str; // Display the elements of the array
}
</script>
<input type=text id='t1'><input type=button value='Add' onClick='add_element()';>
<div id=disp></div>
</body>
</html>
Marky Mark