Any word yet?

J

joep

Can anybody show me how to grab a parameter in ruby?

I have:

<%
require "dbi"
require 'cgi'
cgi = CGI.new

year = cgi.params['year']
make = cgi.params['make']
category = cgi.params['category']

%>

for passing in from another form.

What I cannot get to work is:

<script>

function someFunc(str_string)
{

var js_string = str_string;
alert(js_string); <-----everything looks good here

My web page won't even come up because of the following line(sudo).
It doesn't like the 'js_string'

<% some ruby code equals= js_string%>


}

</script>

How do I dereference a Javascript var?

Any input would be great!

Thanks
 
J

Jan Svitok

Can anybody show me how to grab a parameter in ruby?

I have:

<%
require "dbi"
require 'cgi'
cgi = CGI.new

year = cgi.params['year']
make = cgi.params['make']
category = cgi.params['category']

%>

for passing in from another form.

What I cannot get to work is:

<script>

function someFunc(str_string)
{

var js_string = str_string;
alert(js_string); <-----everything looks good here

My web page won't even come up because of the following line(sudo).
It doesn't like the 'js_string'

<% some ruby code equals= js_string%>


}

</script>

How do I dereference a Javascript var?

Any input would be great!

Thanks

Hi,

you're mixing two things:

1. server-side ruby (i.e. it runs on server)
2. client side javascript (runs on client in browser)

The control flow is as follows:

1. server takes your page, runs the embedded ruby, and replaces it
with the result.

xxx<%= 'a' + 'b' %>xxx is the same as xxxabxxx (except for possible
newlines, but we don't care now)

2. the page is sent to browser, and displayed. javascript is executed.
now the page doesn't contain any ruby code.

Your problem with js_string is that there's no javascript involved
when ruby is run, and vice versa. What you have to do is to create a
form and send the data back to the server for processing - see your
year, make, category.
 
J

joep

Can anybody show me how to grab a parameter in ruby?
<%
require "dbi"
require 'cgi'
cgi = CGI.new
year = cgi.params['year']
make = cgi.params['make']
category = cgi.params['category']

for passing in from another form.
What I cannot get to work is:

function someFunc(str_string)
{
var js_string = str_string;
alert(js_string); <-----everything looks good here
My web page won't even come up because of the following line(sudo).
It doesn't like the 'js_string'
<% some ruby code equals= js_string%>


How do I dereference a Javascript var?
Any input would be great!
ThanksHi,

you're mixing two things:

1. server-side ruby (i.e. it runs on server)
2. client side javascript (runs on client in browser)

The control flow is as follows:

1. server takes your page, runs the embedded ruby, and replaces it
with the result.

xxx<%= 'a' + 'b' %>xxx is the same as xxxabxxx (except for possible
newlines, but we don't care now)

2. the page is sent to browser, and displayed. javascript is executed.
now the page doesn't contain any ruby code.

Your problem with js_string is that there's no javascript involved
when ruby is run, and vice versa. What you have to do is to create a
form and send the data back to the server for processing - see your
year, make, category.- Hide quoted text -- Show quoted text -




I gotcha.
I'm still learning this stuff.
Thanks for the direction.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top