2017-03-11 6 views
1

これで、私のコードは、最初の6つのセルの値を「全体」という列に追加します。私は、「全体的」列の最初の5つのセルのみを行い、「出席率」というラベルの列に「出席」値を追加するようにしましたが、「出席」で選択したラジオボタンの値を、 「6」が選択された場合、「出席要因」の欄に0.6が表示されるように、値を10だけ増やします。2つの異なる列にラジオボタンの値を追加

これが行われた後、出席率の列に表示される値の前にテキストを追加することは可能ですか(つまり、 '0.6'の代わりに 'x 0.6'が表示されます)。とにかくここ

は私のコードです:

var overall= $('#overall'); 
 

 
    $(document).ready(function() { 
 
    $(':radio').change(function() { 
 
    var row = $(this).closest('.item'); 
 
    var checkedItems = row.find(":checked") 
 
    if (checkedItems.length == 6) { 
 
    row.find("td.overall").html(getOverall(checkedItems)); 
 
    } 
 
    }) 
 

 
    function getOverall(_checkedItems) { 
 
    var total = 0; 
 
    _checkedItems.each(function() { 
 
    total += parseFloat($(this).val()); 
 
    }); 
 
    return total; 
 
    } 
 

 

 
    }); 
 

 
    var tableToExcel = (function() { 
 
    var uri = 'data:application/vnd.ms-excel;base64,' 
 
    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}<\/x:Name><x:WorksheetOptions><x:DisplayGridlines/><\/x:WorksheetOptions><\/x:ExcelWorksheet><\/x:ExcelWorksheets><\/x:ExcelWorkbook><\/xml><![endif]--><\/head><body><table>{table}<\/table><\/body><\/html>' 
 
    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } 
 
    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } 
 
    return function(table, name) { 
 
    if (!table.nodeType) table = document.getElementById(table) 
 
    var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML} 
 
    window.location.href = uri + base64(format(template, ctx)) 
 
    } 
 
    })()
table { 
 
    font-family: arial, sans-serif; 
 
    border-collapse: collapse; 
 
    width: 115%; 
 
} 
 
td, 
 
th { 
 
    border: 1px solid #dddddd; 
 
    text-align: left; 
 
    padding: 5px; 
 
    text-align: center 
 
} 
 
tr:nth-child(even) { 
 
    background-color: #dddddd; 
 
} 
 
div { 
 
    padding-top: 10px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table id="copyTable"> 
 
    <thead> 
 
    <tr> 
 
    <th>Team</th> 
 
    <th>Player</th> 
 
    <th>Number</th> 
 
    <th>Skating</th> 
 
    <th>Shooting</th> 
 
    <th>Passing</th> 
 
    <th>Puck Control</th> 
 
    <th>Team Play</th> 
 
    <th>Attendance</th> 
 
    <th>Overall</th> 
 
    <th>Attendance Factor</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
<tr class="item" data-id="1"> 
 
    <td></td> 
 
    <td></td> 
 
    <td></td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="skating" value="1">1 
 
     <input type="radio" name="skating" value="2">2 
 
     <input type="radio" name="skating" value="3">3 
 
     <input type="radio" name="skating" value="4">4 
 
     <input type="radio" name="skating" value="5">5 
 
     <br> 
 
     <input type="radio" name="skating" value="6">6 
 
     <input type="radio" name="skating" value="7">7 
 
     <input type="radio" name="skating" value="8">8 
 
     <input type="radio" name="skating" value="9">9 
 
     <input type="radio" name="skating" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="shooting" value="1">1 
 
     <input type="radio" name="shooting" value="2">2 
 
     <input type="radio" name="shooting" value="3">3 
 
     <input type="radio" name="shooting" value="4">4 
 
     <input type="radio" name="shooting" value="5">5 
 
     <br> 
 
     <input type="radio" name="shooting" value="6">6 
 
     <input type="radio" name="shooting" value="7">7 
 
     <input type="radio" name="shooting" value="8">8 
 
     <input type="radio" name="shooting" value="9">9 
 
     <input type="radio" name="shooting" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="passing" value="1">1 
 
     <input type="radio" name="passing" value="2">2 
 
     <input type="radio" name="passing" value="3">3 
 
     <input type="radio" name="passing" value="4">4 
 
     <input type="radio" name="passing" value="5">5 
 
     <br> 
 
     <input type="radio" name="passing" value="6">6 
 
     <input type="radio" name="passing" value="7">7 
 
     <input type="radio" name="passing" value="8">8 
 
     <input type="radio" name="passing" value="9">9 
 
     <input type="radio" name="passing" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="puck_control" value="1">1 
 
     <input type="radio" name="puck_control" value="2">2 
 
     <input type="radio" name="puck_control" value="3">3 
 
     <input type="radio" name="puck_control" value="4">4 
 
     <input type="radio" name="puck_control" value="5">5 
 
     <br> 
 
     <input type="radio" name="puck_control" value="6">6 
 
     <input type="radio" name="puck_control" value="7">7 
 
     <input type="radio" name="puck_control" value="8">8 
 
     <input type="radio" name="puck_control" value="9">9 
 
     <input type="radio" name="puck_control" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="team_play" value="1">1 
 
     <input type="radio" name="team_play" value="2">2 
 
     <input type="radio" name="team_play" value="3">3 
 
     <input type="radio" name="team_play" value="4">4 
 
     <input type="radio" name="team_play" value="5">5 
 
     <br> 
 
     <input type="radio" name="team_play" value="6">6 
 
     <input type="radio" name="team_play" value="7">7 
 
     <input type="radio" name="team_play" value="8">8 
 
     <input type="radio" name="team_play" value="9">9 
 
     <input type="radio" name="team_play" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="attendance" value="1">1 
 
     <input type="radio" name="attendance" value="2">2 
 
     <input type="radio" name="attendance" value="3">3 
 
     <input type="radio" name="attendance" value="4">4 
 
     <input type="radio" name="attendance" value="5">5 
 
     <br> 
 
     <input type="radio" name="attendance" value="6">6 
 
     <input type="radio" name="attendance" value="7">7 
 
     <input type="radio" name="attendance" value="8">8 
 
     <input type="radio" name="attendance" value="9">9 
 
     <input type="radio" name="attendance" value="10">10 
 
    </form> 
 
    </td> 
 
    <td class="overall" id="overall"> 
 
    </td> 
 
    <td class="attendance" id="attendance"></td> 
 

 
</tr> 
 
<tr class="item" data-id="2"> 
 
    <td></td> 
 
    <td></td> 
 
    <td></td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="skating" value="1">1 
 
     <input type="radio" name="skating" value="2">2 
 
     <input type="radio" name="skating" value="3">3 
 
     <input type="radio" name="skating" value="4">4 
 
     <input type="radio" name="skating" value="5">5 
 
     <br> 
 
     <input type="radio" name="skating" value="6">6 
 
     <input type="radio" name="skating" value="7">7 
 
     <input type="radio" name="skating" value="8">8 
 
     <input type="radio" name="skating" value="9">9 
 
     <input type="radio" name="skating" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="shooting" value="1">1 
 
     <input type="radio" name="shooting" value="2">2 
 
     <input type="radio" name="shooting" value="3">3 
 
     <input type="radio" name="shooting" value="4">4 
 
     <input type="radio" name="shooting" value="5">5 
 
     <br> 
 
     <input type="radio" name="shooting" value="6">6 
 
     <input type="radio" name="shooting" value="7">7 
 
     <input type="radio" name="shooting" value="8">8 
 
     <input type="radio" name="shooting" value="9">9 
 
     <input type="radio" name="shooting" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="passing" value="1">1 
 
     <input type="radio" name="passing" value="2">2 
 
     <input type="radio" name="passing" value="3">3 
 
     <input type="radio" name="passing" value="4">4 
 
     <input type="radio" name="passing" value="5">5 
 
     <br> 
 
     <input type="radio" name="passing" value="6">6 
 
     <input type="radio" name="passing" value="7">7 
 
     <input type="radio" name="passing" value="8">8 
 
     <input type="radio" name="passing" value="9">9 
 
     <input type="radio" name="passing" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="puck_control" value="1">1 
 
     <input type="radio" name="puck_control" value="2">2 
 
     <input type="radio" name="puck_control" value="3">3 
 
     <input type="radio" name="puck_control" value="4">4 
 
     <input type="radio" name="puck_control" value="5">5 
 
     <br> 
 
     <input type="radio" name="puck_control" value="6">6 
 
     <input type="radio" name="puck_control" value="7">7 
 
     <input type="radio" name="puck_control" value="8">8 
 
     <input type="radio" name="puck_control" value="9">9 
 
     <input type="radio" name="puck_control" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="team_play" value="1">1 
 
     <input type="radio" name="team_play" value="2">2 
 
     <input type="radio" name="team_play" value="3">3 
 
     <input type="radio" name="team_play" value="4">4 
 
     <input type="radio" name="team_play" value="5">5 
 
     <br> 
 
     <input type="radio" name="team_play" value="6">6 
 
     <input type="radio" name="team_play" value="7">7 
 
     <input type="radio" name="team_play" value="8">8 
 
     <input type="radio" name="team_play" value="9">9 
 
     <input type="radio" name="team_play" value="10">10 
 
    </form> 
 
    </td> 
 
<td> 
 
<form action=""> 
 
    <input type="radio" name="attendance" value="1">1 
 
    <input type="radio" name="attendance" value="2">2 
 
    <input type="radio" name="attendance" value="3">3 
 
    <input type="radio" name="attendance" value="4">4 
 
    <input type="radio" name="attendance" value="5">5 
 
    <br> 
 
    <input type="radio" name="attendance" value="6">6 
 
    <input type="radio" name="attendance" value="7">7 
 
    <input type="radio" name="attendance" value="8">8 
 
    <input type="radio" name="attendance" value="9">9 
 
    <input type="radio" name="attendance" value="10">10 
 
</form> 
 
</td> 
 
    <td class="overall" id="overall"> 
 
    </td> 
 
    <td class="attendance" id="attendance"></td> 
 

 
</tr> 
 
    </tbody> 
 
</table> 
 
<div align="center"> 
 
<input type="button" onclick="tableToExcel('copyTable')" value="Export to Excel"> 
 
</div>

答えて

2

さてあなたが行うことができますがこのように、主にattendanceラジオボタンを実行して、全体のデータを実行し、他のデータと区別します。

var overall= $('#overall'); 
 

 
    $(document).ready(function() { 
 
     $(':radio').change(function(e) { 
 
     var row = $(this).closest('.item'); 
 
     var checkedItems = row.find(":checked:not(:radio[name='attendance'])") 
 
     if(e.target.name != "attendance"){ 
 
     
 
     if (checkedItems.length == 5) { 
 
      row.find("td.overall").html(getOverall(checkedItems)); 
 
     } 
 
     }else{ 
 
     \t row.find("td.attendance").html("x "+parseFloat($(this).val()/10).toFixed(1)); 
 
     } 
 
    }) 
 

 
    function getOverall(_checkedItems) { 
 
    var total = 0; 
 
    _checkedItems.each(function() { 
 
    total += parseFloat($(this).val()); 
 
    }); 
 
    return total; 
 
    } 
 

 

 
    }); 
 

 
    var tableToExcel = (function() { 
 
    var uri = 'data:application/vnd.ms-excel;base64,' 
 
    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}<\/x:Name><x:WorksheetOptions><x:DisplayGridlines/><\/x:WorksheetOptions><\/x:ExcelWorksheet><\/x:ExcelWorksheets><\/x:ExcelWorkbook><\/xml><![endif]--><\/head><body><table>{table}<\/table><\/body><\/html>' 
 
    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) } 
 
    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) } 
 
    return function(table, name) { 
 
    if (!table.nodeType) table = document.getElementById(table) 
 
    var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML} 
 
    window.location.href = uri + base64(format(template, ctx)) 
 
    } 
 
    })()
table { 
 
    font-family: arial, sans-serif; 
 
    border-collapse: collapse; 
 
    width: 115%; 
 
} 
 
td, 
 
th { 
 
    border: 1px solid #dddddd; 
 
    text-align: left; 
 
    padding: 5px; 
 
    text-align: center 
 
} 
 
tr:nth-child(even) { 
 
    background-color: #dddddd; 
 
} 
 
div { 
 
    padding-top: 10px; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table id="copyTable"> 
 
    <thead> 
 
    <tr> 
 
    <th>Team</th> 
 
    <th>Player</th> 
 
    <th>Number</th> 
 
    <th>Skating</th> 
 
    <th>Shooting</th> 
 
    <th>Passing</th> 
 
    <th>Puck Control</th> 
 
    <th>Team Play</th> 
 
    <th>Attendance</th> 
 
    <th>Overall</th> 
 
    <th>Attendance Factor</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
<tr class="item" data-id="1"> 
 
    <td></td> 
 
    <td></td> 
 
    <td></td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="skating" value="1">1 
 
     <input type="radio" name="skating" value="2">2 
 
     <input type="radio" name="skating" value="3">3 
 
     <input type="radio" name="skating" value="4">4 
 
     <input type="radio" name="skating" value="5">5 
 
     <br> 
 
     <input type="radio" name="skating" value="6">6 
 
     <input type="radio" name="skating" value="7">7 
 
     <input type="radio" name="skating" value="8">8 
 
     <input type="radio" name="skating" value="9">9 
 
     <input type="radio" name="skating" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="shooting" value="1">1 
 
     <input type="radio" name="shooting" value="2">2 
 
     <input type="radio" name="shooting" value="3">3 
 
     <input type="radio" name="shooting" value="4">4 
 
     <input type="radio" name="shooting" value="5">5 
 
     <br> 
 
     <input type="radio" name="shooting" value="6">6 
 
     <input type="radio" name="shooting" value="7">7 
 
     <input type="radio" name="shooting" value="8">8 
 
     <input type="radio" name="shooting" value="9">9 
 
     <input type="radio" name="shooting" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="passing" value="1">1 
 
     <input type="radio" name="passing" value="2">2 
 
     <input type="radio" name="passing" value="3">3 
 
     <input type="radio" name="passing" value="4">4 
 
     <input type="radio" name="passing" value="5">5 
 
     <br> 
 
     <input type="radio" name="passing" value="6">6 
 
     <input type="radio" name="passing" value="7">7 
 
     <input type="radio" name="passing" value="8">8 
 
     <input type="radio" name="passing" value="9">9 
 
     <input type="radio" name="passing" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="puck_control" value="1">1 
 
     <input type="radio" name="puck_control" value="2">2 
 
     <input type="radio" name="puck_control" value="3">3 
 
     <input type="radio" name="puck_control" value="4">4 
 
     <input type="radio" name="puck_control" value="5">5 
 
     <br> 
 
     <input type="radio" name="puck_control" value="6">6 
 
     <input type="radio" name="puck_control" value="7">7 
 
     <input type="radio" name="puck_control" value="8">8 
 
     <input type="radio" name="puck_control" value="9">9 
 
     <input type="radio" name="puck_control" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="team_play" value="1">1 
 
     <input type="radio" name="team_play" value="2">2 
 
     <input type="radio" name="team_play" value="3">3 
 
     <input type="radio" name="team_play" value="4">4 
 
     <input type="radio" name="team_play" value="5">5 
 
     <br> 
 
     <input type="radio" name="team_play" value="6">6 
 
     <input type="radio" name="team_play" value="7">7 
 
     <input type="radio" name="team_play" value="8">8 
 
     <input type="radio" name="team_play" value="9">9 
 
     <input type="radio" name="team_play" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="attendance" value="1">1 
 
     <input type="radio" name="attendance" value="2">2 
 
     <input type="radio" name="attendance" value="3">3 
 
     <input type="radio" name="attendance" value="4">4 
 
     <input type="radio" name="attendance" value="5">5 
 
     <br> 
 
     <input type="radio" name="attendance" value="6">6 
 
     <input type="radio" name="attendance" value="7">7 
 
     <input type="radio" name="attendance" value="8">8 
 
     <input type="radio" name="attendance" value="9">9 
 
     <input type="radio" name="attendance" value="10">10 
 
    </form> 
 
    </td> 
 
    <td class="overall" id="overall"> 
 
    </td> 
 
    <td class="attendance" id="attendance"></td> 
 

 
</tr> 
 
<tr class="item" data-id="2"> 
 
    <td></td> 
 
    <td></td> 
 
    <td></td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="skating" value="1">1 
 
     <input type="radio" name="skating" value="2">2 
 
     <input type="radio" name="skating" value="3">3 
 
     <input type="radio" name="skating" value="4">4 
 
     <input type="radio" name="skating" value="5">5 
 
     <br> 
 
     <input type="radio" name="skating" value="6">6 
 
     <input type="radio" name="skating" value="7">7 
 
     <input type="radio" name="skating" value="8">8 
 
     <input type="radio" name="skating" value="9">9 
 
     <input type="radio" name="skating" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="shooting" value="1">1 
 
     <input type="radio" name="shooting" value="2">2 
 
     <input type="radio" name="shooting" value="3">3 
 
     <input type="radio" name="shooting" value="4">4 
 
     <input type="radio" name="shooting" value="5">5 
 
     <br> 
 
     <input type="radio" name="shooting" value="6">6 
 
     <input type="radio" name="shooting" value="7">7 
 
     <input type="radio" name="shooting" value="8">8 
 
     <input type="radio" name="shooting" value="9">9 
 
     <input type="radio" name="shooting" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="passing" value="1">1 
 
     <input type="radio" name="passing" value="2">2 
 
     <input type="radio" name="passing" value="3">3 
 
     <input type="radio" name="passing" value="4">4 
 
     <input type="radio" name="passing" value="5">5 
 
     <br> 
 
     <input type="radio" name="passing" value="6">6 
 
     <input type="radio" name="passing" value="7">7 
 
     <input type="radio" name="passing" value="8">8 
 
     <input type="radio" name="passing" value="9">9 
 
     <input type="radio" name="passing" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="puck_control" value="1">1 
 
     <input type="radio" name="puck_control" value="2">2 
 
     <input type="radio" name="puck_control" value="3">3 
 
     <input type="radio" name="puck_control" value="4">4 
 
     <input type="radio" name="puck_control" value="5">5 
 
     <br> 
 
     <input type="radio" name="puck_control" value="6">6 
 
     <input type="radio" name="puck_control" value="7">7 
 
     <input type="radio" name="puck_control" value="8">8 
 
     <input type="radio" name="puck_control" value="9">9 
 
     <input type="radio" name="puck_control" value="10">10 
 
    </form> 
 
    </td> 
 
    <td> 
 
    <form action=""> 
 
     <input type="radio" name="team_play" value="1">1 
 
     <input type="radio" name="team_play" value="2">2 
 
     <input type="radio" name="team_play" value="3">3 
 
     <input type="radio" name="team_play" value="4">4 
 
     <input type="radio" name="team_play" value="5">5 
 
     <br> 
 
     <input type="radio" name="team_play" value="6">6 
 
     <input type="radio" name="team_play" value="7">7 
 
     <input type="radio" name="team_play" value="8">8 
 
     <input type="radio" name="team_play" value="9">9 
 
     <input type="radio" name="team_play" value="10">10 
 
    </form> 
 
    </td> 
 
<td> 
 
<form action=""> 
 
    <input type="radio" name="attendance" value="1">1 
 
    <input type="radio" name="attendance" value="2">2 
 
    <input type="radio" name="attendance" value="3">3 
 
    <input type="radio" name="attendance" value="4">4 
 
    <input type="radio" name="attendance" value="5">5 
 
    <br> 
 
    <input type="radio" name="attendance" value="6">6 
 
    <input type="radio" name="attendance" value="7">7 
 
    <input type="radio" name="attendance" value="8">8 
 
    <input type="radio" name="attendance" value="9">9 
 
    <input type="radio" name="attendance" value="10">10 
 
</form> 
 
</td> 
 
    <td class="overall" id="overall"> 
 
    </td> 
 
    <td class="attendance" id="attendance"></td> 
 

 
</tr> 
 
    </tbody> 
 
</table> 
 
<div align="center"> 
 
<input type="button" onclick="tableToExcel('copyTable')" value="Export to Excel"> 
 
</div>

+0

出席時に「10」をクリックすると、「x 1」の代わりに「x 1.0」が表示されるようにすることはできますか? – ChippeRockTheMurph

+0

@ChippeRockTheMurphもちろん、私の答えを更新し、答えを解析し、 '.toFixed(1)'を使ってください。 1は右側の桁数です。 – Roljhon

+0

@Rolijhonありがとう。 – ChippeRockTheMurph

2

これはそれを行う必要があります。

$(document).ready(function() { 
    $(':radio').change(function() { 
    var row = $(this).closest('.item'); 
    var checkedItems = row.find(":checked") 
    if (checkedItems.length == 6) { 
     row.find("td.overall").html(getOverall(checkedItems)); 
     row.find("td.attendance").html(getAttendance(checkedItems)); 
    } 
    }) 

    function getOverall(_checkedItems) { 
    var total = 0; 
    var cnt = 0; 
    _checkedItems.each(function() { 
     if(cnt++ < 5) 
     total += parseFloat($(this).val()); 
    }); 
    return total; 
    } 
    function getAttendance(_checkedItems) { 
    var attendance = 0; 
    var cnt = 0; 
    _checkedItems.each(function() { 
     if(cnt++ == 5) 
     attendance = parseFloat($(this).val()); 
    }); 
    return ("x " + (attendance/10).toFixed(1)); 
    } 
}); 

あなたがここでそれを試すことができます。https://jsfiddle.net/FrancisMacDougall/f3x9qs5s/

+0

それはあなたがそれを表示する出席者に '10' をクリックしたときになるように 'X 1.0' をそれを作る代わりに 'X 1' のすることは可能ですか? – ChippeRockTheMurph

+0

それはすでにそれを行います。 ...ああ、申し訳ありません - 私はそれを更新します... – fmacdee

+0

ちょうどこれを行う:return( "x" +(attendance/10).toFixed(1)); – fmacdee

関連する問題