3
setInterval(function(){
$.getJSON("http://127.0.0.1/recebecores/valor.php", function(array) {
quantidade = array[0];
document.getElementById('betAmount').value = quantidade;
var tempo = document.getElementById("banner").textContent;
var match = tempo.match(/[^\d](\d+)/);
var nr = match && match[1];
if(nr === "4"){
var red = document.getElementById("red").textContent;
var green = document.getElementById("green").textContent;
var black = document.getElementById("black").textContent;
console.log(red);
console.log(black);
if(red>black){
$("#enviarpreto").click();
}else if(black>red){
$("#enviarvermelho").click();
}
}
});
},1000);
Well, sometimes in the if(red > black) and elseif part, he clicks the wrong button instead of clicking the right one.
What could be the mistake?
Thank you.
What are the values of the variables
red
andblack
?– Roberto de Campos
Are numbers, which may vary....
– Gonçalo
If it’s numbers, we’re missing one parse. You are storing the values in string in the variables.
– Pedro Camara Junior
parse, what do you mean? Could you give an example?
– Gonçalo
Convert the value of stored variables to
string
inint
using parseint or infloat
using parseFloat.– Pedro Camara Junior