Can someone please help me? How do I get a value other than true or false in the checkbox? Example: I click on the "test" checkbox. I do not want the word "test" to appear, not true. Thanks!
Can someone please help me? How do I get a value other than true or false in the checkbox? Example: I click on the "test" checkbox. I do not want the word "test" to appear, not true. Thanks!
You must enter a value for the input checkbox. See the code below
<!DOCTYPE html>
<html>
<body>
Checkbox: <input type="checkbox" id="meucheckbox" value="QualquerValor">
<p>Clique no botão para ver o resultado do checkbox</p>
<button onclick="pegarValor()">Testar</button>
<p id="demo"></p>
<script>
function pegarValor() {
var x = document.getElementById("meucheckbox").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>