where CheckedValues() is a javascript function
if the radio button is selected, then i want to increase the vote_count
value by 1
vote_count is the rails variable.
how can i use this variable in javascript, i have tried as follows,
<script type="text/javascript">
var vote = <%= @voting.vote_count %>;
var radiobutton = document.getElementById("radio");
function CheckedValues(){
if(radiobutton.checked){
vote = vote+1
};
};
</script>
but it didnt increase the value.
any help or advice would be helpful
--
Posted via http://www.ruby-forum.com/.
<%= radio_button :nominees, :count %>
<%= observe_field(:nominees_count, :on=>'click', :frequency=>0.25,
:update => :vote_count, :with => :nominees_count, :url => { :action =>
:nominees_count_them}) %>
<div id="vote_count"></div>
Then put the method in your controller:
def nominees_count_them
# add your counts here
vote_count = (perform a find on the model for the current vote count)
vote_count += 1
# Do something with your vote count like update to a table
end
The div id is only there so you can view if it's working. Just look
through observe_field and checkbox and radio buttons. You'll find what
you need to get it working.
This may or may not work for you. I'm just going by what I remember. I
believe the syntax is correct though.