1
I need to take values from a form of type "range" and through the values of each <input>
of <form>
want to store in a var
Javascript within the page itself <html>
so that within a function verifica()
I can perform conditions like if
and else
or switch checking a value from an average of the values by the amount of questions and direct to another page <html>
according to the results.
Head code:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="../css/jquery.mobile-1.4.5.min.css" />
<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.mobile-1.4.5.min.js"></script> -->
<script type="text/javascript" src="../cordova.js"></script>
<script type="text/javascript"></script>
JS Code:
<script>
validar = function(){
var soma = 0;
$('input[type=range]').each(function() {
soma += parseInt($(this).val());
});
// depurando variável com da média
soma = (soma/3);
switch (soma) {
case 0:
location.href="depreop01.html";
break;
case 1:
location.href="depreop02.html";
break;
case 2:
location.href="depreop03.html";
break;
default:
location.href="questionario.html";
}
} // fim da função validar
</script>
HTML code:
<form name="form" target="blank">
<label class="ui-hidden-accessible"></label>
<p>1. PERGUNTA</p>
<input type="range" name="fum-dep-1" id="fum-dep-1" min="0" max="10" value="10" step="1" data-highlight="true">
<label for="slider" class="ui-hidden-accessible"></label>
<p>2. PERGUNTA</p>
<input type="range" name="fum-dep-2" id="fum-dep-2" min="0" max="10" value="10" step="1" data-highlight="true">
<label for="slider" class="ui-hidden-accessible"></label>
<p>3. PERGUNTA</p>
<input type="range" name="fum-dep-3" id="fum-dep-3" min="0" max="10" value="10" step="1" data-highlight="true">
<br>
<input type="button" name="submit" onclick="validar();" value="Enviar" id="submit" />
</form>
have you done anything? Where is your difficulty? Put the code to see how it is.
– Nelson Aguiar
Okay @Nelsonaguide
– Marcílio Aguiar
Take a look ai @Nelsonaguide the end missed another photo because I have no reputation yet but it’s only the <input type="Submit" onclick="validate();" data-Theme="b" value="Submit" />
– Marcílio Aguiar
http://meta.pt.stackoverflow.com/questions/5483/manual-de-como-n%C3%83o-fazer-perguntas/5485#5485
– MagicHat
Take a look over there if that’s really what you need, I hope it helps.
– Nelson Aguiar