PDA

View Full Version : adding elements to an array using prompt


gencoglu4
05-09-2008, 08:32 PM
Hi there,
I am tring to add ten elements in an array1 using a prompt function..
and another ten elements in another array2 and so on... I need to create 7 different arrays with say numbers /names ..Then I will create new lines of 6 elements randomly selected from these arrays...hope you can help me..I m not sure how to use push() function either..
Thanks

<script>
array1=prompt(".e1,e2,e3,e4.....","......")
array2=prompt(".e1,e2,e3,e4.....","......")
array3=prompt(".e1,e2,e3,e4.....","......")
..........
function bir()
{

b1=Math.floor(Math.random()*array1.length)+1;
b2=Math.floor(Math.random()*array2.length)+1;
b3=Math.floor(Math.random()*array3.length)+1;
..........
document.write(b1+b2+b3.......b6)
document.write("<br>")


}

</scipt>

Thanks

shyam
05-10-2008, 07:08 AM
var ar = [];
ar.push(1);
ar.push(4);
ar.push(5);
// now the array contains [1, 4, 5]