Click to See Complete Forum and Search --> : Testing my array
SugarGirl
02-11-2003, 10:07 AM
I am trying to create a way to test to see what is stored in my arrays, would this work.
I have a .js that contains the below function:
var test;
function Testing(){
for(var i=0;i<test.length;i++){
test[i] = i;
document.write(test[i]);
}
What do I need to write in my html to call this function?
cyberade
02-11-2003, 10:51 AM
Have a look at this. Is this the sort of thing you're after?
<HTML>
<HEAD>
<TITLE>Test Array</TITLE>
<SCRIPT language="javascript">
var test = new Array();
test[0]="a";
test[1]="b";
test[2]="c";
test[3]="d";
function Testing(){
document.write(test+" >>>>> ");
for(var i=0;i<test.length;i++){
document.write(test[i]+" ");
test[i] = i;
document.write(test[i]+" ");
}
}
</SCRIPT>
</HEAD>
<body onload="Testing();">
</BODY>
</HTML>
HTH
SugarGirl
02-11-2003, 11:15 AM
I wanted to create the array and the function to print the array in a .js library file, and then make a call to that function in my html?
Can someone help???
cyberade
02-12-2003, 10:17 AM
Sorry if I misunderstood you the first time.
If I understand you correctly now, what you need to do is copy everything between the script tags into a .js file - but not the tags themselves.
That puts the array creation in the .js file and the function to display it in the same file.
Replace the script tags with
<script src="some name.js"></script>
You can then call your function anywhere in your html as though it had been written inline.
HTH