0
About teaching, I want the beginner class to cost 20 per lesson and the advanced 40, differentiating using radio buton, and the amount of class with input type range, but I don’t know much about js and wanted this help, ae goes the code that I adapted from the internet but it only serves for beginner class because it does the amount of class times 20 and wanted that collected the variable of the radio and used in the place of the 20.
OBG
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
<section>
<h3>Escolha o pacote desejado</h3><hr>
Iniciante<input type="radio" name="radio" id="iniciante" checked /><br>
Avançado<input type="radio" name="radio" id="avancado" />
<h4>Quantidade de Aulas:</h4>
<input id="price" class="slider" type="range" min="1" max="30" value="1"/>
<span id="resultado1" style="font-size: 25px;"></span>
<h4>Total:</h4>
<p id="resultado2">Preço: </p>
</section>
<script>
var p = document.getElementById("price"),
res1 = document.getElementById("resultado1"),
res2 = document.getElementById("resultado2");
p.addEventListener("input", function () {
res1.innerHTML = p.value;
}, false);
p.addEventListener("mouseup", function () {
res2.innerHTML = "Preço: " + p.value * 20 + ",00";
}, false);
</script>
</body>
</html>
Why don’t you use input type number? Or select?
– Maury Developer
I find the radiobutton more beautiful, sorry for the answer
– Vinicius
Use method:
var curso = (document.getElementById("iniciante").checked) ? 20 : 40;
– Maury Developer