How to get the input value in real time? [duplicate]

1

I have this input that is hidden and disabled:

<input type="text" disabled="" id="valorMascara" class="oculto" name="valorMascara">

There are two inputs type radio that sends hidden pro input value, I want to get the value of this input in real time and play inside a variable in PHP , NO SUBMIT, NO SEND FORM, I WANT TO PICK IN REAL TIME .

    
asked by anonymous 12.04.2018 / 23:22

2 answers

0

You will need js, it will look something like this:

$('#iddoinput').keyup(function(){

   var text = $(this).val();
   alert(text);
   //Aqui dentro você faz o que quer, manda pra um arquivo php com ajax
   //ou sla, vai depender do que você quer fazer

});
    
12.04.2018 / 23:47
0

You can do this through an AJAX request:

The script you could use on the client side would be:

$('#id-do-input').on('change', function() {
  var $this = $(this);

  $.post('update.php', {
    param: $this.val()
  }, alert('Enviado!'));
});

And on the server side:

<?php

$param = $_POST['param'];

if (! $param) {
  echo 'Nada foi recebido.';
  exit;
}

// Do stuff...

echo 'Dados recebidos!';
    
12.04.2018 / 23:54