Well, I'm making a person use a "range" and decide a value, so the person changes the range, a search is being done in the database about a game and its value, use ajax with php to This, however, is giving you an error, can you help me?
Good morning,
So I just put the .value at the end of the document.getElementById ('game')
var jogo = document.getElementById('jogo').value;
You are trying to send the game input and not the value of the field in that code
Test there to verify that the request is going with both parameters.
"php / select-coach.php? value = 1 & game = 3"
function criarReq() {
try{
return new XMLHttpRequest();
} catch (e) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
}catch (e) {
console.log("Seu navegador não suporta Ajax!");
//return null;
}
}
}
}
function getDados() {
var valor = document.getElementById('coachValue').value;
var coach = document.getElementById('coachs');
var jogo = document.getElementById('jogo').value;
var xmlreq = new criarReq();
console.log("php/select-coach.php?valor="+valor+"&jogo="+jogo);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="range" id="coachValue" value="1">
<input type="text" id="coachs" value="2">
<input type="text" id="jogo" value="3">
<input type="button" value="send" onclick="getDados()">
</body>
</html>
Friend, line 6 looks like this:
$jogo=intval($_GET['jogo']);
change this part leaving it like this:
$jogo=$_GET['jogo'];