How to pass an array as a parameter?

S

SM

Hello,
Such a simple question and i can't find the answer(see code below).
Here it is:

I have a function: ini()
In that function, i call a function (load_CDThumbnail) that creates an
array and returns the newly created array
Then, another function is called (show) that needs to pass the newly
created array as a parameter. That's the part that i don't know how to
program
How to pass an array as a parameter?


Thanks
Marco


function ini()
{
var thumbnail = load_CDThumbnail();
show(thumbnail); ??????
}


function load_CDThumbnail()
{
var cdThumbnail = new Array();

...

return cdThumbnail;
}


function show(???thumbnail???)
{
...
for(var i=0; i<thumbnail.length; i++)
{
alert("testing" + i);
}
...
}
 
L

Lee

SM said:
Hello,
Such a simple question and i can't find the answer(see code below).
Here it is:

I have a function: ini()
In that function, i call a function (load_CDThumbnail) that creates an
array and returns the newly created array
Then, another function is called (show) that needs to pass the newly
created array as a parameter. That's the part that i don't know how to
program
How to pass an array as a parameter?


Thanks
Marco


function ini()
{
var thumbnail = load_CDThumbnail();
show(thumbnail); ??????
}


function load_CDThumbnail()
{
var cdThumbnail = new Array();

...

return cdThumbnail;
}


function show(???thumbnail???)
{
...
for(var i=0; i<thumbnail.length; i++)
{
alert("testing" + i);
}
...
}

There's no trick to it:

<html>
<body>
<script type="text/javascript">

function ini()
{
var thumbnail = load_CDThumbnail();
show(thumbnail);
}

function load_CDThumbnail()
{
var cdThumbnail = new Array();
cdThumbnail.push("hello");
cdThumbnail.push("world");
return cdThumbnail;
}

function show(thumbnail)
{
for(var i=0;i<thumbnail.length;i++)
{
alert("testing: "+thumbnail)
}
}

ini();

</script>
</body>
</html>


--
 
S

SM

SM said:




Hello,
Such a simple question and i can't find the answer(see code below).
Here it is:
I have a function: ini()
In that function, i call a function (load_CDThumbnail) that creates an
array and returns the newly created array
Then, another function is called (show) that needs to pass the newly
created array as a parameter. That's the part that i don't know how to
program
How to pass an array as a parameter?

function ini()
{
var thumbnail = load_CDThumbnail();
show(thumbnail); ??????
}
function load_CDThumbnail()
{
var cdThumbnail = new Array();

return cdThumbnail;
}
function show(???thumbnail???)
{
...
for(var i=0; i<thumbnail.length; i++)
{
alert("testing" + i);
}
...
}

There's no trick to it:

<html>
<body>
<script type="text/javascript">

function ini()
{
var thumbnail = load_CDThumbnail();
show(thumbnail);
}

function load_CDThumbnail()
{
var cdThumbnail = new Array();
cdThumbnail.push("hello");
cdThumbnail.push("world");
return cdThumbnail;
}

function show(thumbnail)
{
for(var i=0;i<thumbnail.length;i++)
{
alert("testing: "+thumbnail)
}
}

ini();

</script>
</body>
</html>

--


JEs!!!!!!
Its time for me to rest..

Thanks lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top