问卷:没有选定时,其它 选项的输入框禁用。选择了才可用
This commit is contained in:
parent
c2a7ec4fc7
commit
3d3b46f7f3
|
@ -312,11 +312,21 @@ class PollController < ApplicationController
|
|||
end
|
||||
else
|
||||
#pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案
|
||||
if pv.delete
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "false" ,:percent => format("%.2f" ,@percent)}
|
||||
if params[:vote_text]
|
||||
pv.vote_text = params[:vote_text]
|
||||
if pv.save
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "ok",:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
if pv.delete
|
||||
@percent = get_percent(@poll,User.current)
|
||||
render :json => {:text => "false" ,:percent => format("%.2f" ,@percent)}
|
||||
else
|
||||
render :json => {:text => "failure"}
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif pq.question_type == 3
|
||||
|
|
|
@ -47,12 +47,11 @@
|
|||
},
|
||||
success: function (data) {
|
||||
var dataObj = eval(data);
|
||||
document.getElementById("poll_vote_<%=pq.id %>poll_answer_id_<%=pa.id %>").checked = true;
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
|
||||
//var span = $('#percent');
|
||||
//span.html(dataObj.percent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
function click_<%= pa.id %>(obj)
|
||||
{
|
||||
|
@ -68,10 +67,13 @@
|
|||
if(dataObj.text == "ok")
|
||||
{
|
||||
obj.checked = true;
|
||||
$(obj).parent().parent().parent().parent().find("input[type='text']").attr("disabled", "disabled");
|
||||
$(obj).next('input').removeAttr("disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.checked = false;
|
||||
$(obj).next('input').attr("disabled", "disabled");
|
||||
}
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
|
@ -84,7 +86,7 @@
|
|||
</script>
|
||||
<%= radio_button "poll_vote",pq.id.to_s+"poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current),:disabled => !@can_edit_poll %>
|
||||
<% if pa.answer_text == "" %>
|
||||
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %> placeholder="其他">
|
||||
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa,User.current))?"":"disabled=disabled" %> placeholder="其他">
|
||||
<% else %>
|
||||
<%= pa.answer_text %>
|
||||
<% end %>
|
||||
|
@ -135,9 +137,9 @@
|
|||
},
|
||||
success: function (data) {
|
||||
var dataObj = eval(data);
|
||||
document.getElementById("poll_vote_<%=pq.id %>poll_answer_id_<%=pa.id %>").checked = true;
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
|
||||
//var span = $('#percent');
|
||||
//span.html(dataObj.percent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -155,10 +157,12 @@
|
|||
if(dataObj.text == "ok")
|
||||
{
|
||||
obj.checked = true;
|
||||
$(obj).next('input').removeAttr("disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.checked = false;
|
||||
$(obj).next('input').attr("disabled", "disabled");
|
||||
}
|
||||
var span = $('#percent');
|
||||
span.html(dataObj.percent);
|
||||
|
@ -171,7 +175,7 @@
|
|||
</script>
|
||||
<input class="ur_radio" id="poll_vote_<%=pq.id %>poll_answer_id_<%=pa.id %>" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
|
||||
<% if pa.answer_text == "" %>
|
||||
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %> placeholder="其他">
|
||||
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa,User.current))?"":"disabled=disabled" %> placeholder="其他">
|
||||
<% else %>
|
||||
<%= pa.answer_text %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue