Hi,
am having the code like this
<%=radio_button(:nominees, count, :onclick => ‘CheckedValues();’)%> <%=
response.nomination %>
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,
but it didnt increase the value.
any help or advice would be helpful
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.
Thanks for the quick reply Alpha,
Actually what i want is while selecting the radio button the vote_count
should be increased.
i have tried thst with update_attribute and increment methods. but the
vote_count is not increased .
could you give some advice about how to increase the vote_count based on
the selection.
Alpha B. wrote:
You should use observe_field with what you are trying to accomplish.
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.