Adding Model display "Yes" to a jscript function which gets total from radio button inputs of value "1"
any ideas on how to resolve whats below?
Edit- seems some people don't understand the issue from the title and the code so here it is, I have a running total which increases each time a radio button on my page is changed but I have 4 forms which have radio buttons and each after being saved has a display view instead of edit, my issue is I don't know how best to get the display value into my total function. Also in the开发者_如何学Python display view I have the 2 different ways in which my questions are displayed, switch for 3 forms and rest for final form.
Edit2- Noticed that some people think if code is all they see at the top of page then some don't read down to text so moving it up to top in hopes of making it clearer
Edit view
<td class="aCell">
<%= Html.RadioButton(i+"_1", "1", new { @onclick = "getTotal()", @class = "sectionCB" }) %>
</td>
<td class="aCell">
<%= Html.RadioButton(i+"_1", "0", new { @onclick = "getTotal()", @class = "sectionCB", @checked = "checked" })%>
Display view
switch (i)
{
case 1:
{
qna1 = (Model.Q1A1) ? "Yes" : "No";
qna2 = (Model.Q1A2) ? "Yes" : "No";
break;
}
<tr>
<td class="bCell" >
H/k
</td>
<td class="aCell" colspan="2"><%: (Model.Q9A1) ? "Yes" : "No"%></td>
Total function
function getTotal() {
var $inputs = $('#dAnswers :input.sectionCB');
var x = 0;
$inputs.each(function () {
if ($(this).val() == "1" && $(this).attr('checked')) { x++; }
});
var total = Math.round(x / 51 * 100);
$('#sTotal').html(total + '%');
}
Total display
<span style="font-size: 250%;" id="sTotal">0%</span>
精彩评论