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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top