469,275 Members | 1,795 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

How to pass an array as a parameter?

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);
}
...
}

May 25 '07 #1
2 44152
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[i])
}
}

ini();

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

May 25 '07 #2
SM
On May 25, 4:39 pm, Lee <REM0VElbspamt...@cox.netwrote:
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[i])
}
}

ini();

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

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

Thanks lee

May 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by wilson | last post: by
3 posts views Thread by lukasz.f24 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.