JSFiddle - React, Tailwind, and code Playground

by dixalex

HTML

<table>
  <tbody>
    <tr>
      <td>Atlantic Co-op / Co-op IGA
      </td>
    </tr>
  </tbody>
</table>

<ul>
  <li>Save-On-Foods</li>
  <li>Federated Co-op</li>
  <li>Whole Foods</li>
  <li>Sobeys</li>
  <li>Safeway</li>
  <li>Your Independent Grocer (YIG)</li>
  <li>Loblaws</li>
  <li>Zehrs</li>
  <li>Foodland</li>
  <li>Metro</li>
  <li>Farm Boy</li>
  <li>Longos</li>
  <li>Provigo</li>
  <li>Provigo Le Marche</li>
  <li>IGA</li>
  <li>Atlantic Co-op / Co-op IGA</li>
  <li>Atlantic Superstore</li>
</ul>

JavaScript

function ProcessSubmit() {
  if ($('select').filter(function(index, element) {
      return $(element).val() > 0
    }).length === 3) {
    var m = $('select:first').val();
    var d = ($('select:eq(1)').val() - 1);
    var y = $('select:last').val();
    var birth_date = new Date(y, m, d);
    var today = new Date();
    var diff = (today - birth_date);
    var years = parseInt(Math.floor(diff / (1000 * 60 * 60 * 24 * 365.25), 10));
    var age_input = $('.age_input input[type="text"]');
    age_input.val(years)
  } else {
    $('.age_input input').val('')
  }
}