title: How to Export the Value of a Radio Button to Excel
body: <p>Okay, so I have a table, some of the columns in that table have radio buttons, which I have marked with values 1 through 10, I also have a 'Export to Excel' button that exports that table to a Excel file, however, when it exports it exports the values of all the radio buttons in each of the columns that have radio buttons, I just want it to export the value of the radio button selected in each column, not the values of all of the radio buttons in each column, oh and BTW the 'Export to Excel' button doesn't work in the preview in Stack Overflow so you'll just have to copy the code if you want that to work and save it as a program on your hard drive, anyways here's my code, thanks for your time to try solving this problem:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    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 = '&lt;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"&gt;&lt;head&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;&lt;x:ExcelWorkbook&gt;&lt;x:ExcelWorksheets&gt;&lt;x:ExcelWorksheet&gt;&lt;x:Name&gt;{worksheet}&lt;\/x:Name&gt;&lt;x:WorksheetOptions&gt;&lt;x:DisplayGridlines/&gt;&lt;\/x:WorksheetOptions&gt;&lt;\/x:ExcelWorksheet&gt;&lt;\/x:ExcelWorksheets&gt;&lt;\/x:ExcelWorkbook&gt;&lt;\/xml&gt;&lt;![endif]--&gt;&lt;\/head&gt;&lt;body&gt;&lt;table&gt;{table}&lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt;'
      , 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))
      }
      })()</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>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;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table id="copyTable"&gt;
    &lt;thead&gt;
      &lt;tr&gt;
    &lt;th&gt;Team&lt;/th&gt;
    &lt;th&gt;Player&lt;/th&gt;
    &lt;th&gt;Number&lt;/th&gt;
    &lt;th&gt;Skating&lt;/th&gt;
    &lt;th&gt;Shooting&lt;/th&gt;
    &lt;th&gt;Passing&lt;/th&gt;
    &lt;th&gt;Puck Control&lt;/th&gt;
    &lt;th&gt;Team Play&lt;/th&gt;
    &lt;th&gt;Attendance&lt;/th&gt;
    &lt;th&gt;Overall&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
  &lt;tr class="item" data-id="1"&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="skating" value="1"&gt;1
        &lt;input type="radio" name="skating" value="2"&gt;2
        &lt;input type="radio" name="skating" value="3"&gt;3
        &lt;input type="radio" name="skating" value="4"&gt;4
        &lt;input type="radio" name="skating" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="skating" value="6"&gt;6
        &lt;input type="radio" name="skating" value="7"&gt;7
        &lt;input type="radio" name="skating" value="8"&gt;8
        &lt;input type="radio" name="skating" value="9"&gt;9
        &lt;input type="radio" name="skating" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="shooting" value="1"&gt;1
        &lt;input type="radio" name="shooting" value="2"&gt;2
        &lt;input type="radio" name="shooting" value="3"&gt;3
        &lt;input type="radio" name="shooting" value="4"&gt;4
        &lt;input type="radio" name="shooting" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="shooting" value="6"&gt;6
        &lt;input type="radio" name="shooting" value="7"&gt;7
        &lt;input type="radio" name="shooting" value="8"&gt;8
        &lt;input type="radio" name="shooting" value="9"&gt;9
        &lt;input type="radio" name="shooting" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="passing" value="1"&gt;1
        &lt;input type="radio" name="passing" value="2"&gt;2
        &lt;input type="radio" name="passing" value="3"&gt;3
        &lt;input type="radio" name="passing" value="4"&gt;4
        &lt;input type="radio" name="passing" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="passing" value="6"&gt;6
        &lt;input type="radio" name="passing" value="7"&gt;7
        &lt;input type="radio" name="passing" value="8"&gt;8
        &lt;input type="radio" name="passing" value="9"&gt;9
        &lt;input type="radio" name="passing" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="puck_control" value="1"&gt;1
        &lt;input type="radio" name="puck_control" value="2"&gt;2
        &lt;input type="radio" name="puck_control" value="3"&gt;3
        &lt;input type="radio" name="puck_control" value="4"&gt;4
        &lt;input type="radio" name="puck_control" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="puck_control" value="6"&gt;6
        &lt;input type="radio" name="puck_control" value="7"&gt;7
        &lt;input type="radio" name="puck_control" value="8"&gt;8
        &lt;input type="radio" name="puck_control" value="9"&gt;9
        &lt;input type="radio" name="puck_control" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="team_play" value="1"&gt;1
        &lt;input type="radio" name="team_play" value="2"&gt;2
        &lt;input type="radio" name="team_play" value="3"&gt;3
        &lt;input type="radio" name="team_play" value="4"&gt;4
        &lt;input type="radio" name="team_play" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="team_play" value="6"&gt;6
        &lt;input type="radio" name="team_play" value="7"&gt;7
        &lt;input type="radio" name="team_play" value="8"&gt;8
        &lt;input type="radio" name="team_play" value="9"&gt;9
        &lt;input type="radio" name="team_play" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="attendance" value="1"&gt;1
        &lt;input type="radio" name="attendance" value="2"&gt;2
        &lt;input type="radio" name="attendance" value="3"&gt;3
        &lt;input type="radio" name="attendance" value="4"&gt;4
        &lt;input type="radio" name="attendance" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="attendance" value="6"&gt;6
        &lt;input type="radio" name="attendance" value="7"&gt;7
        &lt;input type="radio" name="attendance" value="8"&gt;8
        &lt;input type="radio" name="attendance" value="9"&gt;9
        &lt;input type="radio" name="attendance" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td class="overall" id="overall"&gt;
    &lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr class="item" data-id="2"&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;&lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="skating" value="1"&gt;1
        &lt;input type="radio" name="skating" value="2"&gt;2
        &lt;input type="radio" name="skating" value="3"&gt;3
        &lt;input type="radio" name="skating" value="4"&gt;4
        &lt;input type="radio" name="skating" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="skating" value="6"&gt;6
        &lt;input type="radio" name="skating" value="7"&gt;7
        &lt;input type="radio" name="skating" value="8"&gt;8
        &lt;input type="radio" name="skating" value="9"&gt;9
        &lt;input type="radio" name="skating" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="shooting" value="1"&gt;1
        &lt;input type="radio" name="shooting" value="2"&gt;2
        &lt;input type="radio" name="shooting" value="3"&gt;3
        &lt;input type="radio" name="shooting" value="4"&gt;4
        &lt;input type="radio" name="shooting" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="shooting" value="6"&gt;6
        &lt;input type="radio" name="shooting" value="7"&gt;7
        &lt;input type="radio" name="shooting" value="8"&gt;8
        &lt;input type="radio" name="shooting" value="9"&gt;9
        &lt;input type="radio" name="shooting" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="passing" value="1"&gt;1
        &lt;input type="radio" name="passing" value="2"&gt;2
        &lt;input type="radio" name="passing" value="3"&gt;3
        &lt;input type="radio" name="passing" value="4"&gt;4
        &lt;input type="radio" name="passing" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="passing" value="6"&gt;6
        &lt;input type="radio" name="passing" value="7"&gt;7
        &lt;input type="radio" name="passing" value="8"&gt;8
        &lt;input type="radio" name="passing" value="9"&gt;9
        &lt;input type="radio" name="passing" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="puck_control" value="1"&gt;1
        &lt;input type="radio" name="puck_control" value="2"&gt;2
        &lt;input type="radio" name="puck_control" value="3"&gt;3
        &lt;input type="radio" name="puck_control" value="4"&gt;4
        &lt;input type="radio" name="puck_control" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="puck_control" value="6"&gt;6
        &lt;input type="radio" name="puck_control" value="7"&gt;7
        &lt;input type="radio" name="puck_control" value="8"&gt;8
        &lt;input type="radio" name="puck_control" value="9"&gt;9
        &lt;input type="radio" name="puck_control" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;form action=""&gt;
        &lt;input type="radio" name="team_play" value="1"&gt;1
        &lt;input type="radio" name="team_play" value="2"&gt;2
        &lt;input type="radio" name="team_play" value="3"&gt;3
        &lt;input type="radio" name="team_play" value="4"&gt;4
        &lt;input type="radio" name="team_play" value="5"&gt;5
        &lt;br&gt;
        &lt;input type="radio" name="team_play" value="6"&gt;6
        &lt;input type="radio" name="team_play" value="7"&gt;7
        &lt;input type="radio" name="team_play" value="8"&gt;8
        &lt;input type="radio" name="team_play" value="9"&gt;9
        &lt;input type="radio" name="team_play" value="10"&gt;10
      &lt;/form&gt;
    &lt;/td&gt;
  &lt;td&gt;
  &lt;form action=""&gt;
    &lt;input type="radio" name="attendance" value="1"&gt;1
    &lt;input type="radio" name="attendance" value="2"&gt;2
    &lt;input type="radio" name="attendance" value="3"&gt;3
    &lt;input type="radio" name="attendance" value="4"&gt;4
    &lt;input type="radio" name="attendance" value="5"&gt;5
    &lt;br&gt;
    &lt;input type="radio" name="attendance" value="6"&gt;6
    &lt;input type="radio" name="attendance" value="7"&gt;7
    &lt;input type="radio" name="attendance" value="8"&gt;8
    &lt;input type="radio" name="attendance" value="9"&gt;9
    &lt;input type="radio" name="attendance" value="10"&gt;10
  &lt;/form&gt;
  &lt;/td&gt;
    &lt;td class="overall" id="overall"&gt;
    &lt;/td&gt;
  
  &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;div align="center"&gt;
  &lt;input type="button" onclick="tableToExcel('copyTable')" value="Export to Excel"&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>