Onclick problem

onclick=“document.forms[‘search_form’].search_title.value=’<%= u[0]
%>’;”

When u[0] = blah’blah (with a single quote), i get the error in firebug:
missing ; before statement
[Break on this error]
document.forms[‘search_form’].search_tit…f(getElementById(‘search_id’).value==’’)

…value=‘blah’blah’; is causing problems. I guess the ’ is ending the
string. How can I workaround this, while still retaining the '?

Thanks

…value=‘blah’blah’; is causing problems. I guess the ’ is ending the
string. How can I workaround this, while still retaining the '?

Convert it to " using one of the rails helpers or CGI htmlescape
methods…

It should still appear as a ’ in your form.

…value=‘blah’blah’; is causing problems. I guess the ’ is ending the
string. How can I workaround this, while still retaining the '?

Just escape it. I think there’s already a function in rails for
escaping strings for javascript.

Fred

escape_javascript(something)

On Aug 8, 1:38 pm, Frederick C. [email protected]

Richard L. wrote:

escape_javascript(something)

On Aug 8, 1:38 pm, Frederick C. [email protected]

Sweet, works great, thanks!

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