How to check and uncheck HTML input type radio using HTML button with JavaScript

1 Answer

0 votes
<!DOCTYPE html>
<html>
<body>

<form>
  <input type="radio" name="namephp" id="idphp">PHP<br />
</form>

<button onclick="check()">Check PHP</button>
<button onclick="uncheck()">Uncheck PHP</button>

<script>
function check() {
    document.getElementById("idphp").checked = true;
}
function uncheck() {
    document.getElementById("idphp").checked = false;
}
</script>

</body>
</html>

 



answered Jun 18, 2018 by avibootz
edited Jun 18, 2018 by avibootz

Related questions

1 answer 329 views
1 answer 213 views
1 answer 217 views
1 answer 136 views
1 answer 161 views
1 answer 242 views
...