KTU
February 4, 2008, 2:58pm
1
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.
KTU
February 4, 2008, 4:24pm
2
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 ‘)’
KTU
February 4, 2008, 6:36pm
3
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]
KTU
February 4, 2008, 6:39pm
4
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) %>
KTU
February 4, 2008, 5:15pm
5
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