Template

by niighthawk

HTML

<!DOCTYPE html>
<html lang=fr>
<head>
<meta charset=utf-8>
<title>Untitled Document</title>
<script>
      // Cette fonction est prise d'ici : https://stackoverflow.com/a/4652513
      function reduce(numerator, denominator) {
        var gcd = function gcd(a, b) {
          return b ? gcd(b, a % b) : a;
        };
        gcd = gcd(numerator, denominator);
        return [numerator / gcd, denominator / gcd];
      }

      function output() {
        var value1 = +document.getElementById('value1').value; // En rajoutant un "+" on covertis en nombre...
        var resultinches = document.getElementById('resultinches');
        var resultmm = document.getElementById('resultmm');

        if (value1 >= 0 && value1 <= 130) {
          resultinches.textContent = "PAS DISPONIBLE";
        } else {
          var result = (1003 - (3.5 * value1)) * 0.03937008;
          var roundResult = Math.round(result * 16) / 16;
          var pouces = Math.trunc(roundResult);
          var n = (roundResult - pouces) * 16;
          var str;

          if (n == 0) str = " pouces";
          else {
            var fractionSimple = reduce(n, 16);
            str = " pouces et " + fractionSimple[0] + "/" + fractionSimple[1];
          }
          resultinches.textContent = pouces + str;
          resultmm.textContent = Math.round(result * 25.4) + " mm";
        }
      }
    </script>
</head>

<body>

<form>
  <table border="0" margin="0" padding="0" cellspacing="0" cellpadding="0">
  <tr height="1" style="border:0px;">
    <td style="width:100px"></td>
    <td style="width:100px"></td>
    <td style="width:100px"></td>
    <td style="width:100px"></td>
  </tr>
  <tr style="border:0px;" >
    
  </tr>
  <tr height="24.99375px" style="border:0px;" >
    <td colspan="4" style="height:20px;  background-color:#FFC000; border-top: solid 1px #7B7B7B; border-bottom: solid 1px #7B7B7B; border-right: 0px; border-left: 0px; font-size: 16px; font-family:Calibri; color:#000000; font-weight: bold;...