Limit the value of TextBox by taking into account the sum of its values

0

I have the following table in which are included 3 textbox's corresponding to percentages, which I realize is that when the user inserts the values in the first 2 TextBox's, the 3rd value appears with the remaining amount of the subtraction of 100 with the sum of the other two TextBox's. For example, if you write in the 1st textb's the value of 50, and in the 2nd the value of 25, it will have to appear in the 3rd automatically the value of 25. It can be in Javascript or Jquery.

<table id="myTable6">
  <thead>
      <tr>
           <th><label>Peso das Nota</label></th>
      </tr>
  </thead>
    <tbody>
        <form><td><label>Testes: </label><input type="text" name="nome" id="mySelect11"> 
                  <label>Exame:  </label><input type="text" name="nome" id="mySelect12">
                  <label>Trabalhos:</label>  <input type="text" name="nome" id="mySelect13"></td>


    </tbody>
</table>
    
asked by anonymous 17.12.2016 / 17:50

1 answer

1

$("#mySelect12").on("blur",function(){
  var valor1 = parseFloat($("#mySelect11").val());
  var calc = 100 - (parseFloat($(this).val()) + valor1);
  $("#mySelect13").val(calc);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><tableid="myTable6">
  <thead>
    <tr>
      <th>
        <label>Peso das Nota</label>
      </th>
    </tr>
  </thead>
  <tbody>
    <form>
      <td>
        <label>Testes:</label>
        <input type="text" name="nome" id="mySelect11">
        <br><br>
        <label>Exame:</label>
        <input type="text" name="nome" id="mySelect12">
        <br><br>
        <label>Trabalhos:</label>
        <input type="text" name="nome" id="mySelect13">
      </td>
  </tbody>
</table>
    
17.12.2016 / 19:49