Observe field & javascript

Hi

How I can change this:

<%= radio_button(“response_item”, id, 1) %><%= h(imitem.grpname) %><br/

Help

to work on radio button selection to call that same showdesc
javascript ? ie. I want to embed that javascript
inside of radio button so that once it is selected (clicked) it will
launch javascript call to showdesc call.

This works ok

<%= radio_button(“response_item”, id, 1, :onchange => “showdesc(‘4’)”)
%>

but now how can i replace value=4 with db id ?

<% for imitem in @imitems %>
<%= radio_button(“response_item”, id, 1, :onchange => “showdesc(‘4’)”)
%><%= h(imitem.grpname) %>

<% end %>

I tried this one:

<%= radio_button(“response_item”, id, 1, :onchange => “showdesc(’<%=
h(imitem.id) %>’)”) %>

but this throws an error:

compile error
/usr/local/webhome/mdm/app/views/imitems/showgroup.html.erb:11: syntax
error, unexpected tCONSTANT, expecting ‘)’
_erbout.concat(( submit_tag ‘Next’ ).to_s); _erbout.concat “\n”
^
/usr/local/webhome/mdm/app/views/imitems/showgroup.html.erb:11:
unterminated string meets end of file
/usr/local/webhome/mdm/app/views/imitems/showgroup.html.erb:11: syntax
error, unexpected $end, expecting ‘)’

Hi

Thanks for this one. One more thing.

<%= radio_button :imitem, :id, imitem.id, :id => “id”, onchange =>
“showdesc()” %> <%= h(imitem.grpname) %>

<%= radio_button(“id”, id, 1, :onchange =>
“showdesc(‘#{h(imitem.id)}’)”) %> <%= h(imitem.grpname) %>

What about 1st line. It does not like onchange setting in there. Now
if I use 2nd line I get strange HTML code like this:

demo

I would like this to be just

demo

On Feb 4, 6:14 pm, Frederick C. [email protected]

ok I found the answer.

It needs to be like this:

<%= radio_button :imitem, :id, imitem.id, :id => “id”, :onchange =>
“showdesc (’#{h(imitem.id)}’)” %> <%= h(imitem.grpname) %>

On 4 Feb 2008, at 15:23, KTU wrote:

%><%= h(imitem.grpname) %>

<% end %>

I tried this one:

<%= radio_button(“response_item”, id, 1, :onchange => “showdesc(’<%=
h(imitem.id) %>’)”) %>

At this point it’s just regular ruby (ie not an erb thingy) so

<%= radio_button(“response_item”, id, 1, :onchange =>
“showdesc(’#{h(imitem.id)}’)”) %>

Should do the trick

Fred