Pick up a dice value and play on var

Asked

Viewed 83 times

0

I’m developing a web server in PLC, in which you’ll be able to take the data from an air hose to see if the pressure is okay. I developed the code in js and set a value to see if it worked, but now I want to take the value of this pressure and if it reaches a certain number, it goes to the page in question

follows the code

$('#bot).on('
click ',function(){
})

var i = 0;

setInterval(function() {
            $('counter').text(i);
            i++;
            if (i == 6) {
                $('#pag-1).show();
                    $('pag-2).hide();
                    }
                }, 1000)

in the var i, you know what function I use to pull the data from a particular location?

  • When you say "pull the data from a given location" would it be to pull the value of an input (form field)? If yes, just use the following var i = $('#idCampo'). val();

  • this, however the values are being pulled from a program in real time, in the case of id field I would have to set a value for when the program arrived at it, identify?

  • Yes, the field in question from where it will pull would have to have an id.

  • long, thank you

1 answer

0


If your intention is to catch the value of a input, just do the following:

jQuery(function($){
   var i = $('#numero').val(); 

   console.log(i);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Número <input type="text" id="numero" value="5">

  • thanks Cara but where do I determine the entry of this imput? if the value will be played in real time

  • Will this value come from a PHP code? If so, you can do the following: Number <input type="text" id="number" value="<? php echo $variableComValue; ?>">

  • in reality this value is being generated in the aunt portal, within a PLC that I am making for a web server, my difficulty is just this, how to take this value of the PLC and play in an html

  • You would have to see how this PLC works to see how it works with the data and find a way to pass the value to the input in the form.

  • Leandro in the following code var i = $('#counter'). val(); Setinterval( Function () { i++; if ( i = 5000000 ) { what do you think is not rolling? I was able to play the value to the screen in real time, but now I just need to take that specific value and play an action as in this example

Browser other questions tagged

You are not signed in. Login or sign up in order to post.