You'll have to show some simplified code. If you do this:
Code:
var o;
function doSomething()
{
o = {name: "Joe"};
}
doSomething();
alert(o.name);
Then the o object declared at the beginning will have a property "name" with the value "Joe". If you use var inside the function then you are creating a different local variable.
Addition:
Sorry, didn't read your code carefully enough. JavaScript does not support passing by reference, you have two choices. Either just refer to the global object in the function or you assign the properties from one object to the other:
Code:
var o = {name: "Joe"};
function changeObjectName(obj, name)
{
obj.name = name;
}
function changeObjectName2(name)
{
o.name = name;
}
alert(o.name);
changeObjectName(o, "Joseph");
alert(o.name);
changeObjectName2("Joe Fawcett");
alert(o.name);
--
Joe (
Microsoft MVP - XML)