Get javascript value

hi to all,

i’ve this javascript function :

function km(str_dir) {
  map = new GMap2(document.getElementById("map_canvas"));
  directionsPanel = document.getElementById("route");
  directions = new GDirections(map, directionsPanel);
  directions.load(str_dir);
  GEvent.addListener(directions,"load", function() {
  var dist= directions.getDistance().meters;
  return dist;
  });
}

i call the function from the controller in this way:

@arg=“500 Memorial Drive, Cambridge, MA to Fenway Park, Boston, MA”
page.call (“km”, @arg)

all work…

the problem is that i want to take the result of javascript function in
the controller…
How can i use the variable “dist” inside the controller??

thanks in advance

andre

Andrea C. wrote:

hi to all,

i’ve this javascript function :

function km(str_dir) {
  map = new GMap2(document.getElementById("map_canvas"));
  directionsPanel = document.getElementById("route");

You gotta send request to your controller/method using Ajax, that is the
only way i could think of :slight_smile:

Jamal S. wrote:

Andrea C. wrote:

hi to all,

i’ve this javascript function :

function km(str_dir) {
  map = new GMap2(document.getElementById("map_canvas"));
  directionsPanel = document.getElementById("route");

You gotta send request to your controller/method using Ajax, that is the
only way i could think of :slight_smile:

thanks

i think i have to learn a little bit ajax :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs