单选题选择答案

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 def commit_answer
@pv = get_poll_vote(User.current.id,params[:poll_question_id]) @pv = get_poll_vote(User.current.id,params[:poll_question_id])
if params[:poll_vote][:poll_answer_id] if params[:poll_answer_id]
@pv.poll_answer_id = params[:poll_vote][:poll_answer_id] @pv.poll_answer_id = params[:poll_answer_id]
end end
if params[:poll_vote][:vote_text] if params[:vote_text]
@pv.vote_text = params[:poll_vote][:vote_text] @pv.vote_text = params[:vote_text]
end end
@pv_saved = false @pv_saved = false
if @pv.save if @pv.save

View File

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