Select to view content in your preferred language

Passing a string through a button in info template

780
2
11-20-2012 09:04 AM
PrasannaRaghavendar
Occasional Contributor
Hi,
I have an info template like this.

infoTemplate=new esri.InfoTemplate("<div align='center'><input type='button' value='Use this location' onclick='test(x,y,z)'></div>");


I have defined x,y,z as:
x=5;
y=10;
z="Sairam";


I am getting an error on my browser as " 'Sairam' is undefined".
When I pass only numeric values, it works fine. But if i pass a String, i get this undefined error. Could some one tell me how i could pass a String as a parameter on this info template button onclick function?

Thanks
Prasanna
0 Kudos
2 Replies
TracySchloss
Honored Contributor
What happens if you put quotes around z in the onClick?
0 Kudos
PrasannaRaghavendar
Occasional Contributor
Hi schlot,

The error persists even if I put it inside quotes. I did a workaround to make it work. I globally declared a Javascript Array, stored the string in it and passed the index of the array through the info template. With that index, I can access my content from the array.

Thanks
Prasanna
0 Kudos