Hey all I'm having problems getting the correct value of a checkbox. I
have an observe field that calls a javascript function whenever the
checkbox is changed. But for whatever reason the checkbox value always
seems to be 1. Perhaps I'm using the wrong syntax to get the value?...
My code is below, any help would be greatly appreciated.
<% remote_form_for :nAd, @nAd, :url => { :action => "update" } do |f| %>
<%= f.check_box :excludeAd %>
<%= f.text_area :whyExcludeAd, :cols => 30, :rows => 5 %>
<% end %>
<%= observe_field("nAd_excludeAd", :function =>
"displayElementByValue('nAd_excludeAd', 'nAd_whyExcludeAd');") %>
function displayElementByValue(elementToCheck, elementToChange)
{
// value is always 1!!
var value = $(elementToCheck).value;
formElement = document.getElementById(elementToChange);
}
Basically when this function is called it changes the display property
of the "nAd_whyExcludAd" element, however I can't get it to correctly
show the value from "nAd_excludeAd", though the function is being called
correctly.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---