Update array in one function by another function

Hi,

I have small problem and I am stuck with it for days without any solution.

So I have a function that has an array,

function arrjoin( )
{
var a = new Array (1,1,1,1,1,1,0,0,0,0);
var c = a.join(“~”);
return (c);
}

I have another function that call the arrjoin(). But before doing so, I get a value from an input field based on which i need to update the array in arrjoin() and save that as the new array(I mean same array but with the update value).

function xxxx( )
{
document.getElementById(“graphhide”).value = index;
var b = joinarr( );
}

This is my current function. In this before I call joinarr( ) I need to update the array a in joinarr( ) with the value=index, that I am fetching here and save the array. (Haven’t implemented yet) This process keeps on occurring every time a index value is generated. Thus in the next iteration the array a in arrjoin( ) show not be array show here but the array with the updates values.

I am eventually transferring the array to server side to do some processing based on current value of the array. Any idea on how to achieve the above situation will be of great help to me. Thank you all in advance for your reply.

-SK

Here is an example that should put you on track:

var myDynamicArray = new function myDynamicArray() {
this.myArray = null;

this.init = function() {
this.myArray = [‘1’, ‘2’, ‘3’, ‘4’];
}

this.newArray = function() {
this.myArray = [‘5’, ‘6’, ‘7’, ‘8’];
}

}

myDynamicArray.init();
alert(myDynamicArray.myArray);
myDynamicArray.newArray();
alert(myDynamicArray.myArray);

this script alerts you after every time the array changes. As you can see if you want the same array to be accessible throughout the entire lifespan of the session, it needs to be accessible globally.