Jump to content

[SOLVED] Passing variables between functions


jellis

Recommended Posts

Hi all,

 

Reasonably urgent matter (assignment is due in about an hour  ???)

 

I'm attempting to pass an array in a function call which is being called from within another function... like so

 

function foo(f){

array[0] = joe;
array[1] = smith;

// Call new function and pass array
newWindow.call(array);
} // End define function

function newWindow(array){

// Do stuff with array

}

 

I've spent the last couple of hours googling the problem... however, it appears I just do not understand the way javascript works...

 

I've tried declaring the array outside of the functions... but no joy.

 

Any help would be appreciated.

Link to comment
Share on other sites

For those that cared (and for future reference)... I'm a twit!

 

It was simply a case of calling the new function and passing the argument in the function call... as you would do with any other function call.

 

Turned out I had a clash with some variable names versus input id's that was causing the script to just halt.  Luckily the teacher sorted the stuff out before I handed it in.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.