push array values using javascript array push()
by Ramya[ Edit ] 2009-08-21 12:06:23
Push Array Values outside the loop using Javascript Array Push():
Javascript array push() allows user to push array values to outside of the loop inorder to access all the array values.
for eg,
<script>
var arr = new Array();
function test(n){
//returns some values here
}
for(i = 0; i <= 5; i++)
{
arr.push(test(i));
}
document.getElementById('res').value = arr;
</script>
<input type=text id='res' size=25>
In the above example array values will be stored in array variable "arr" and all the values are assigned to textbox using the array variable "arr".