/    Sign up×
Community /Pin to ProfileBookmark

passing object as a parameter in javascript -missing ] after element list

Hello everyone,

I am trying to pass a object in to the function as a parameter and i am getting following error in javascript

missing ] after element list…

the application handle the object but when it generate the script for method

[code]
“<a href=”javascript:mapManager.ZoomToGeoFence(“+[COLOR=”Red”]obj[/COLOR]+”)”>”+obj.Name + “</a>”
[/code]

it replace the parameter to “[object Object]”

I have pasted a sample code for your reference

[code]
function GetGeoFencesAsList()
{
var result=”;
device = loadDevice(’12’)

if(device.GeoFences.GeoFenceList.length==0)
result = ‘No GeoFences Set’;
else{
for(fence in device.GeoFences.GeoFenceList){
var obj = new geoFence(device.GeoFences.GeoFenceList[fence]);
alert(obj.GetXml);
[COLOR=”DarkGreen”] result+= “<a href=”javascript:mapManager.ZoomToGeoFence(“+[COLOR=”Red”]obj[/COLOR]+”)”>”+obj.Name + “</a>, “;[/COLOR]
}
//trim the last comma for neatness
result = result.slice(0,result.length-2);
}
return result;

}

MapManager.prototype.ZoomToGeoFence= function(geofence)
{
alert(geofence.Name);
}

function geoFence(obj)
{
this.CommandStatus = obj.CommandStatus;
this.Continous = obj.Continous;
this.DeviceID = obj.DeviceID;
this.Enabled = obj.Enabled;
this.Entry = obj.Entry;
this.Exit = obj.Exit;
this.GeoFenceAlert = obj.GeoGenceAlert;
this.GetXml = obj.GetXml;
this.ID = obj.ID;
this.Latitude1= obj.Latitude1;
this.Latitude2 = obj.Latitude2;
this.Longitude1= obj.Longitude1;
this.Longitude2 = obj.Longitude2;
this.Name = obj.Name;
this.Number = obj.Number;
this.Shape = obj.Shape;
}
[/code]

thanks
Ameet

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Jul 25.2008 — You cannot. that javascript will run in a totally different scope, so you have to make it global for it to work.
×

Success!

Help @ameet11_81 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...