Q:

How do I get a label to check a radio input when clicked?

I am creating a user login/register form on a website and I'm using radio inputs to display either the login form or the register form. Upon loading the page, it defaults to the login form. If the Register link (really a label for an input) at the bottom is clicked it hides the login form and replaces it with the register form. This part is working fine.
The problem is when you are on the register form and you click the Login link (again, a label for an input) at the bottom of the form, it stays on the register form. I have used the browser code inspector and it continues to list login as checked even when it is showing the register form.
Here is the css and html:

article {
  &#portofentry {
    >div {
      &.container {
        >input {
          &[type="radio"] {
            display: none;
          }
          &[name="login"] {
            &:checked {
              ~div {
                &.container {
                  >form {
                    &[name="loginForm"] {
                      display: block;
                    }
                    &[name="registerForm"] {
                      display: none;
                    }
                  }
                  &.links {
                    >div {
                      &.login {
                        display: none;
                      }
                      &.register,
                      &.forgot {
                        display: block;
                        margin-top: 0;
                      }
                    }
                  }
                }
              }
            }
          }
          &[name="register"] {
            &:checked {
              ~div {
                &.container {
                  >form {
                    &[name="registerForm"] {
                      display: block;
                    }
                    &[name="loginForm"] {
                      display: none;
                    }
                  }
                  &.links {
                    >div {
                      &.register,
                      &.forgot {
                        display: none;
                      }
                      &.login {
                        display: block;
                      }
                    }
                  }
                }
              }
            }
          }
        }
        >div {
          &.container {
            >form {
              display: none;
              >div {
                &::after {
                  content: '';
                  display: table;
                  clear: both;
                }
                >div {
                  &.vDivide {
                    position: absolute;
                    left: 50%;
                    transform: translate(-50%);
                    border: 1px solid $light-grey;
                    height: 17.5rem;
                    @media only screen and (min-width: 120em) {
                      height: 26rem;
                    }
                    @media only screen and (min-width: 135em) {
                      height: 34.17rem;
                    }
                    >span {
                      &.vDivideText {
                        position: absolute;
                        top: 50%;
                        transform: translate(-50%, -50%);
                        background-color: $faint-navy;
                        border: 1px solid $light-grey;
                        border-radius: 50%;
                        padding: .8rem 1rem;
                        color: $off-white;
                        text-transform: uppercase;
                      }
                    }
                  }
                  &.full {
                    &.half {
                      >button,
                      >input {
                        width: calc(100% - 4rem);
                        display: inline-block;
                        margin: 1rem;
                      }
                      &:nth-of-type(3) {
                        >button,
                        >input {
                          margin: 1rem 1rem 1rem 3rem;
                        }
                      }
                    }
                  }
                  >input {
                    &[type="text"],
                    &[type="password"] {
                      margin: 2rem;
                      padding: 1.5rem;
                      width: calc(100% - 4rem);
                    }
                  }
                  >label {
                    color: $grey;
                    margin-left: 3.5rem;
                    font-weight: 300;
                    @media only screen and (min-width: 120em) {
                      font-size: 3rem;
                    }
                    >input {
                      &[type="date"] {
                        padding: 1.5rem;
                        width: auto;
                        background: none;
                        border: none;
                        border-radius: .5rem;
                        border-right: 1px solid $light-grey;
                        border-left: 1px solid $light-grey;
                        text-decoration: none;
                        margin: 0 auto;
                        @media only screen and (min-width: 75em) {
                          font-size: 3rem;
                          font-weight: 300;
                          padding: 1.5rem;
                        }
                        &:hover {
                          box-shadow: 0 0 1rem rgba($faint-navy, .5);
                          background: none;
                        }
                        &:focus {
                          box-shadow: 0 0 1rem rgba($faint-navy, 1);
                          background: none;
                        }
                      }
                    }
                  }
                  >p {
                    text-align: center;
                  }
                  >button {
                    margin: 2rem;
                    width: calc(100% - 4rem);
                  }
                }
              }
            }
            &.links {
              background: $faint-grey;
              margin: 2rem;
              padding: 1.5rem;
              width: calc(100% - 4rem);
              border-radius: 0 0 .5rem .5rem;
              >div {
                text-align: center;
                >label {
                  cursor: pointer;
                }
              }
            }
          }
        }
      }
    }
  }
}
<article id="portofentry">
  <div class="container">
    <input type="radio" name="login" id="login" checked>
    <input type="radio" name="register" id="register">
    <div class="container">
      <form action="/members/admit.php" name="loginForm">
        <div>
          <h2>Login</h2>
          <h6>welcome back</h6>
          <div class="vDivide">
            <span class="vDivideText">or</span>
          </div>
          <div class="full half">
            <button type="button" class="google">
       <i class="fab fa-google"></i>&nbsp;&nbsp;&nbsp;Login with Google
      </button>
            <button type="button" class="facebook">
       <i class="fab fa-facebook-f"></i>&nbsp;&nbsp;&nbsp;Login with Facebook
      </button>
            <button type="button" class="linkedin">
       <i class="fab fa-linkedin-in"></i>&nbsp;&nbsp;&nbsp;Login with LinkedIn
      </button>
            <button type="button" class="twitter">
       <i class="fab fa-twitter"></i>&nbsp;&nbsp;&nbsp;Login with Twitter
      </button>
          </div>
          <div class="full half">
            <div class="mob">
              <p>Sign in manually</p>
            </div>
            <input type="text" name="username" placeholder="Username" required>
            <input type="password" name="password" placeholder="Password" required>
            <button type="submit" name="loginNow">Login</button>
          </div>
        </div>
      </form>
      <form action="/members/register/" name="registerForm">
        <div>
          <h2>Register</h2>
          <h6>welcome</h6>
          <div>
            <input type="text" name="firstname" placeholder="First Name" required>
            <input type="text" name="lastname" placeholder="Last Name" required>
            <input type="text" name="email" placeholder="Email" required>
            <label for="dob">Date of Birth:
       <input type="date" name="dob" id="dob" placeholder="Date of Birth" required>
      </label>
            <input type="password" name="password" placeholder="Password" required>
            <input type="password" name="passwordconfirm" placeholder="Confirm Password" required>
            <p>By creating an account you agree to our <a href="/legal/terms-of-use/">Terms &amp; Privacy</a>.</p>
            <button type="submit" name="registerNow">Register</button>
          </div>
        </div>
      </form>
    </div>
    <div class="container links">
      <div class="full half register">
        <label for="register">Register</label>
      </div>
      <div class="full half forgot">
        <a href="#">Forgot password?</a>
      </div>
      <div class="login">
        Already have an account? <label for="login">Login</label>
      </div>
    </div>
  </div>
</article>

Both of the inputs have ids and I know that both of them work because it defaults to one on load and I can click the other to make it appear. I just can't get it to go back to the login screen when clicking on the Login label.
What am I missing or doing wrong here?

A:

I just figured out what I was doing wrong.
<input type="radio" name="login" id="login" checked>
<input type="radio" name="register" id="register">

I was using different names for the radio inputs here. Because they are options for the same group, they need to have the same name. So...
<input type="radio" name="form-type" id="login" checked>
<input type="radio" name="form-type" id="register">

...this fixes the problem. I really need to quit working late into the night--I'd have far less of these issues if I did!

