Calculate existence

0

I'm doing a module that tells me the number of templates that have delivered a total of 100.

I want that when entering a number in ENTREGADAS I subtract in NO_ENTREGADAS that is worth 100, that is:

Example:  - if% co_of% is worth 0,% co_of% will be 100  - yes ENTREGADAS , NO_ENTREGADAS ;  - ENTREGADAS= 25 , NO_ENTREGADAS= 75

So far I have something like this:

function entregaplanillas() {

  if (document.form1.ENTREGADAS.value = 0) {
    document.form1.NO_ENTREGADAS.value = 100;
  }
}
<input id=" ENTREGADAS " type="number" onblur="entregaplanillas();"></input>
<input id=" NO_ENTREGADAS " type="number"></input>
    
asked by Anderviver 23.06.2017 в 17:29
source

3 answers

1

This is a basic example, but I hope you get the idea

amount = document.getElementById("amount");

total = document.getElementById("total");


amount.onchange = function(e) {
  total.value = 100 - parseInt(amount.value);
}
<input id="amount" type="number" value="0"></input>
<input id="total" type="number" value="100"></input>
    
answered by 23.06.2017 / 17:39
source
0

Well, I've already solved it, in case anyone needs the code, it's like this:

function entregaplanillas(){

entregadas = document.getElementById("ENTREGADAS");
sinentregar = document.getElementById("NO_ENTREGADAS");

entregadas.onchange = function(e) {
sinentregar.value = 100 - parseInt(entregadas.value);
  }
}
    
answered by 23.06.2017 в 18:04
0

Using jquery ..... to the event that happens after pressing a key and releasing it it is necessary to place the numeric data type input to not have to do the validation with js that is number

$(document).on("ready", function(e) {

  $("#input1").on("keyup", function(e) {
    var input2;
    if ($("#input1").val() !== "") {

      var input1 = $(this).val();

      input2 = 100 - input1;
    } else {
      input2 = 0;
    }

    $("#input2").val("Entregado " + input2 + " de 100");


  });
});
<body>

  <p>Cantidad Entregada</p>

  <input id="input1" pattern="[0-9]" type="number">
  <p>Entregado a Fecha</p>
  <input id="input2" type="text">

</body>
    
answered by 23.06.2017 в 18:25