vendredi 27 juillet 2018

Radio Button not performing JavaScript action when clicked

I am trying to create a radio button that opens up an additional checkbox. When I run the code, the checkbox is already open. what can I do to fix it?

<script>
  function accountFunction() {
    if (document.getElementById('yesSrm').checked) {
      document.getElementById('acct').style.display = "inline";
    } else {
      document.getElementById('acct').style.display = "none";
    }
</script>
<form>
  <input id="yesSrm" name="yesSrm" type="radio" value="yes" onchange="accountFunction()" />SRM<br/>
  <br/>
  <div id="acct">
    <label for="account">Account</label>
    <input type="checkbox" name="account" id="account"><br/>
  </div>
</form>

How it appears




Aucun commentaire:

Enregistrer un commentaire