Newbie question on using javascript within rails view

Hi, I am using the MapQuest API and I would like to set the name for
the location by using MQLocation.setName(name) …

I have the name in a Order class, and an object order… how can I
combine the ruby code with the javascript ??

<%= order.id %>

var mq = new MQMap("myMap"); var loc1 = new MQLocation(); loc1.setName("test"); ....................... so for loc1 I'd like to set the name to order.name ... how can I do this ??

loc1.setName("<%= order.name %>");

Make sure you include the quotes.

Depending on what possible characters can appear in order.name, you may
also need to escape the text, using the “escape_javascript” helper
method:

loc1.setName("<%= escape_javascript order.name %>");

Snow Man wrote:

loc1.setName("<%= order.name %>");

Make sure you include the quotes.

Depending on what possible characters can appear in order.name, you may
also need to escape the text, using the “escape_javascript” helper
method:

loc1.setName("<%= escape_javascript order.name %>");

Thanks a lot !! that worked :slight_smile: