0
votes

Hi I am trying to pass guid to a function but it gives me error,

Uncaught SyntaxError: Unexpected token }

var gg = "someGuid";     
var callFunction = "<tr class='MenuRow' onclick='myFunctionabc('" + gg + "')'></tr>"

function myFunctionabc(abcd){
    alert(abcd);
}

I am trying on Chrome, any clue ?

Edit

Sorry for some people who don't know what's GUID, its a number like this "0a6bb960-97c4-4099-8e0a-cc5cc81ed451"

1
are you adding the tr to a tableArun P Johny
@RocketHazmat really ? by someGuid I meant GUID... which looks like this "0a6bb960-97c4-4099-8e0a-cc5cc81ed451"Change

1 Answers

8
votes

You need to escape stating and closing quotes of onclick=""

var callFunction = "<tr class='MenuRow' onclick=\"myFunctionabc('" + gg + "')\"></tr>"