473,230 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

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 44455
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John | last post by:
I would like to pass array variables between URLs but I don't know how. I know its possible with sessions, but sessions can become useless if cookies are disabled. I have unsuccessfully tried...
5
by: wilson | last post by:
Dear all, In this time, I want to pass array to function. What should I declare the parameter in the function?i int array or int array? Which one is correct? ...
9
by: Martoon | last post by:
I want to instantiate an STL map with my own compare function, and I want to pass a parameter to the compare function that will be stored and used for all comparisons in that map instance. As an...
3
by: TC | last post by:
I just upgraded some code to VB 2005. When I did so, Visual Studio generated several warnings telling me about things which weren't quite perfect in my code. I resolved all the warnings except one....
2
by: Dud Bug | last post by:
I have a query in an Access db that prompts the user for info. (e.g. a primary key representing a company) before compiling the relevant table of results. This works fine in Access but I want to use...
3
by: Angus | last post by:
I have a program which when downloaded from a server downloads another program from the same web server and then configures the downloaded program. The trouble is I have to hard code in the...
3
by: lukasz.f24 | last post by:
Hello, I'm trying to pass array as an argument into PL/SQL procedure. According to cursor manual (http://cx-oracle.sourceforge.net/html/ cursorobj.html) arrayvar() should be use to do it. I've...
2
by: | last post by:
I have a gridview with a textbox in an ItemTemplate, as below. The OnTextChanged event fires okay but how do I pass a parameter to it, I get an error when I try "OnTextChanged(""SomeData"")". I...
6
by: Max | last post by:
i have a event bind function like this(though it is not so robust): bind$=function(o,evt,fn,cb){ var aE='attachEvent'; var aEL='addEventListener'; if(!o&&o){ return o(evt,fn,!!cb); } return...
1
by: Jorge | last post by:
On Oct 23, 10:36 am, Tuxedo <tux...@mailinator.comwrote: Yes: function first_function (PARAMETER) { preload_image = new Image(800,600); preload_image.onload = function () {...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.