# ruby variable = javascript variable ?

**URL:** <https://discuss.rubyonrails.org/t/ruby-variable-javascript-variable/42525>\
**Category:** rubyonrails-talk\
**Created:** [May 14, 2009, 3:01pm UTC](https://discuss.rubyonrails.org/t/ruby-variable-javascript-variable/42525 "2009-05-14T15:01:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![semi](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@semi](https://discuss.rubyonrails.org/u/semi)\
**Post date:** [May 14, 2009, 3:01pm UTC](https://discuss.rubyonrails.org/t/ruby-variable-javascript-variable/42525/1 "2009-05-14T15:01:25Z")

</div>

Is there a way to store the value of a js variable in a ruby variable? The reason I ask is because, for example, when a google maps api returns the result of let's say the location on the map, it returns it in a js variable. I need to get the value from that variable to be stored in a ruby variable. Is there a way in which I can do that? Thanks.

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [May 14, 2009, 3:33pm UTC](https://discuss.rubyonrails.org/t/ruby-variable-javascript-variable/42525/2 "2009-05-14T15:33:59Z")

</div>

make an http request to your app (either an ajax request or a more traditional form submission)

Fred

---

<div class="post-metadata">

**Author:** ![semi](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@semi](https://discuss.rubyonrails.org/u/semi)\
**Post date:** [May 14, 2009, 8:48pm UTC](https://discuss.rubyonrails.org/t/ruby-variable-javascript-variable/42525/3 "2009-05-14T20:48:04Z")

</div>

Thanks for the idea. I did something like this, but the page keeps reloading over and over:

\<script type="text/javascript"\>

&nbsp;&nbsp;&nbsp;temp = "wechangedit"; &nbsp;&nbsp;&nbsp;window.location.href = "[http://localhost:3000/home/abc](http://localhost:3000/home/abc)? keyword="+temp;

\</script\>

\<%= params[:keyword] %\>
