On my page there is a form where the user chooses a numeric value. I want whenever the user changes the value, the form is sent, without the need to press the "send" button.
The code I tried, but it did not work:
var valor = document.txtForm.valor.value;
var valorant = document.txtForm.valor.value;
while(1){
valor = document.txtForm.valor.value;
if(valor != valorant){
document.valor_analog.submit();
}
valorant = document.txtForm.valor.value;
}
<html>
<body>
<script src="env_aut.js"></script>
<form name ="valor_analog" action="http://192.168.0.3/" method="POST">
<input name="valor" type="range" min="100" max="500" step="10" />
<input type="submit" value="Submit">
</form>
</body>
</html>
I'm using the following code now.
function envia(){
$.post("http://192.168.0.3/",{valor: $("#valor").val()},function(){});
}
<html>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><formid="valor_analog" action="http://192.168.0.3/" method="POST">
<input name="valor" id="valor" type="range" min="100" max="500" step="10" oninput="envia()"/>
<input type="submit" value="Submit">
</form>
</body>
</html>
The only problem is that it's giving way too late.