# Trouble getting dynamic values fed to my javascript

**URL:** <https://www.ruby-forum.com/t/trouble-getting-dynamic-values-fed-to-my-javascript/167819>\
**Category:** Ruby\
**Created:** [May 12, 2009, 11:31pm UTC](https://www.ruby-forum.com/t/trouble-getting-dynamic-values-fed-to-my-javascript/167819 "2009-05-12T23:31:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xeno\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/958977/32.png) [@Xeno\_C](https://www.ruby-forum.com/u/Xeno_C)\
**Post date:** [May 12, 2009, 11:31pm UTC](https://www.ruby-forum.com/t/trouble-getting-dynamic-values-fed-to-my-javascript/167819/1 "2009-05-12T23:31:49Z")

</div>

Say, I usually have .rhtml/eruby access to all my values, but I’m seeing  
this  
weird case, possibly because I’m using https instead of http (I cannot  
think of  
anything else) that doesn’t allow the values from \<%= $x %\> to be  
utilized in  
javascript methods. When I do the following:

\<%  
$x = $cgi[‘x’]  
puts “trace $x: #{$x}”  
%\>

in the source view from the browser it always shows:

even though my logs show the line with “trace $x: value of x”.

What gives? Is this a known or unexpected behavior? Is there a way I  
can get  
around it?

I have tried it several ways, and I know I’m not mistaken.

Sincerely, Xeno

---

<div class="post-metadata">

**Author:** ![Xeno\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/958977/32.png) [@Xeno\_C](https://www.ruby-forum.com/u/Xeno_C)\
**Post date:** [May 12, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/trouble-getting-dynamic-values-fed-to-my-javascript/167819/2 "2009-05-12T23:37:06Z")

</div>

Xeno C. wrote:

eruby --version gives me:

eRuby version 1.0.5  
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]  
----snip—

---

<div class="post-metadata">

**Author:** ![Xeno\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/958977/32.png) [@Xeno\_C](https://www.ruby-forum.com/u/Xeno_C)\
**Post date:** [May 13, 2009, 12:11am UTC](https://www.ruby-forum.com/t/trouble-getting-dynamic-values-fed-to-my-javascript/167819/3 "2009-05-13T00:11:37Z")

</div>

This is kindof a followup of my other email about javascript in my  
.rhtml files  
(eruby with https apache2). What I seem to be generally seeing is that  
anything  
that is not the initial behavior in eruby values that by necessity must  
be set  
outside any blocks in the early \<% %\> stanza.

If this is known stuff, forgive me. I just need a link, or perhaps a  
recommendation to do it another way. I know AJAX goes in Rails, so it  
must go  
here too, right?
