单选题选择答案

This commit is contained in:
z9hang 2015-01-15 10:11:52 +08:00
parent 8dab2057a9
commit d2fadfda08
2 changed files with 13 additions and 12 deletions

View File

@ -113,11 +113,11 @@ class PollController < ApplicationController
#提交答案
def commit_answer
@pv = get_poll_vote(User.current.id,params[:poll_question_id])
if params[:poll_vote][:poll_answer_id]
@pv.poll_answer_id = params[:poll_vote][:poll_answer_id]
if params[:poll_answer_id]
@pv.poll_answer_id = params[:poll_answer_id]
end
if params[:poll_vote][:vote_text]
@pv.vote_text = params[:poll_vote][:vote_text]
if params[:vote_text]
@pv.vote_text = params[:vote_text]
end
@pv_saved = false
if @pv.save

View File

@ -42,21 +42,22 @@
<td>
<label >
<script>
function clickOK()
function click_<%= pa.id %>(obj)
{
$.ajax({
type: "GET",
url: "<%= bid.comment_status == 0 ? start_anonymous_comment_bid_path(bid) : stop_anonymous_comment_bid_path(bid)%>",
data: 'text',
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_answer_id: <%= pa.id %>,
poll_question_id: <%= pq.id %>
},
success: function (data) {
obj.checked = true;
}
});
}
</script>
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"this.form.submit();return false" %>
<%= hidden_field_tag "poll_question_id",pq.id %>
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;" %>
<%= pa.answer_text %>
</label>
</td>