1

 $(function() {
          $("#refresh").click(function() {
             $("#link").load("mathgame.html")
          
        return false;
        })
        })
main{
    width: auto;
    margin: 20px auto;
}
header nav {
    border-radius: 0.4rem;
    margin: 0.5rem auto;
    padding: 0.2rem 1rem;
    width: 140px;
  }

body{
    background: white;
}

.container {
    position: relative;
    border-radius: 5px;
    background-color: #f2f2f2;
    padding: 20px 0 30px 0;
  } 

p
{
    text-align: left;
}
article {
    background: white;
    margin: 1em auto;
    padding: 1rem;
    max-width: 75%;
    text-align: center;
  }
  article h2 {
    font-variant: small-caps;
    letter-spacing: 0.1em;
    word-spacing: 0.2em;
  }
  article p:first-of-type::first-letter {
    font-size: larger;
    
  }
  

article p {
  line-height: 2;
  text-align: left;
  text-indent: 3rem;
}

h2 {
    text-align: center;
}

/*nav*/
nav {
    background: white;
    margin: 0 -0.5rem;
  }
   
  nav::after {
    content: "";
    display: block;
    clear: both;
  }
   
  nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
   
  nav li {
    float: right;
  }
   
  nav a {
    display: block;
    padding: 1rem;
    text-decoration: none;
  }
   
  nav a:hover {
    background: rgb(240, 240, 240);

  }
   
  nav a:active {
    color: #cce;
  }
  li.contains ul {
    display: none;
  }
  li.contains:hover ul {
    background: white;
    display: block;
    position: absolute;
  }
  li.contains li {
    float: none;
    font-size: 0.9rem;
  }

/*containter on home page*/
* {
  box-sizing: border-box;
}


.column {
  float: left;
  width: 50%;
  padding: 15px; 
  column-gap: normal;

}

.p2, .p1 {
  float: right;
}


.row:after {
  content: "";
  display: table;
  clear: both;
}

 

.button:hover {
  background-color: gray; 
  color: white;
}

  input:hover,
.btn:hover {
  opacity: 1;
}
input[type=submit] {
    background-color:gray;
    color: white;
    cursor: pointer;
  }
  input[type=submit]:hover {
    background-color:gray
  }
  
 
  .vl {
    position: absolute;
    left: 50%;
    transform: translate(-50%);
    height: 175px;
  }
  .inner {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #f1f1f1;
    border: 1px solid #ccc;
    border-radius: 50%;
    padding: 8px 10px;
  }
  @media screen and (max-width: 650px) {
    .col {
      width: 100%;
      margin-top: 0;
    }
}
/* styling for login page*/
form {
    border: 3px solid #f1f1f1;
  }
  
 
  input[type=text], input[type=password] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
  }

  button {
    background-color: #4CAF50;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    cursor: pointer;
    width: 100%;
  }
  

  button:hover {
    opacity: 0.8;
  }
  
  
  .cancelbtn {
    width: auto;
    padding: 10px 18px;
    background-color: #f44336;
  }
  
  
  
 

  .container {
    padding: 16px;
  }
  
  
  span.psw {
    float: right;
    padding-top: 16px;
  }
  span.link {
      text-align: center;
  }
  
  @media screen and (max-width: 300px) {
    span.psw {
      display: block;
      float: none;
    }
    .cancelbtn {
      width: 100%;
    }
  }
    /* for contact formn*/
    form {
        margin: auto;
        width: 500px;
      }
      h2 {
          text-align: center;
      }
      
      label {
        display: block;
        font-weight: bold;
        margin: 5px 0px;
      }
      
      legend {
        font-weight: bold;
      }
      
      input,
      select,
      textarea,
      fieldset {
        box-sizing: border-box;
        font-size: large;
        padding: 4px;
        width: 100%;
      }
      
      fieldset {
        margin: 10px 0px;
        padding: 15px;
      }
      
     
      fieldset label,
      label[for='terms'] {
        display: inline;
        font-weight: normal;
      }
      
    
      input[type='checkbox'],
      input[type='radio'] {
        margin: 0 5px;
        width: auto;
      }
      
      button {
        background-color: white;
        color: black;
        font-family: Arial, Helvetica, sans-serif;
        font-size: x-large;
        margin: 10px;
        padding: 5px;
        width: 100%;
      }
      
      
      input:invalid,
      textarea:invalid,
      select:invalid {
        background-color: pink;
        background-position: 99% 5px;
        background-repeat: no-repeat;
      }
      
      select:invalid {
        background-position: 90%;
      }
      
      input:required,
      select:required,
      #container {
        border-bottom: 4px solid black;
      }
      
      input:focus,
      select:focus,
      textarea:focus {
        border-right: 10px  solid blue;
        
      }
      
      label.required,
      legend.required {
        color: black;
        cursor: help;
      }
      
      label.required::after,
      legend.required::after  {
        color: green;
        content: "*";
        font-weight: normal;
      }
      
      label.required:hover::after,
      legend.required:hover::after  {
        content: "field required";
        margin-left: 5px;
      }
      
      input[type='checkbox']:invalid + label {
        color: red;
      }
     /* for the about page*/
     body {
        font-family: Arial, Helvetica, sans-serif;
        margin: 0;
      }
      
      html {
        box-sizing: border-box;
      }
      
      *, *:before, *:after {
        box-sizing: inherit;
      }
      
      .column {
        float: left;
        width: 33.3%;
        margin-bottom: 16px;
        padding: 0 8px;
      }
      
      .card {
        box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
        margin: 8px;
      }
      
      .about-section {
        padding: 50px;
        text-align: center;
        
      }
      
      .container {
        padding: 0 16px;
      }
      
      .container::after, .row::after {
        content: "";
        clear: both;
        display: table;
      }
      
      .title {
        color: grey;
      }
      
      .button {
        border: none;
        outline: 0;
        display: inline-block;
        padding: 7px;
        color: white;
        background-color: darkgray;
        text-align: center;
        cursor: pointer;
        width: 100%;
      }
      
      .button:hover {
        background-color: #555;
      }
     
      
      @media screen and (max-width: 650px) {
        .column {
          width: 100%;
          display: block;
        }
      }
      /* for the quotes*/


      
.slideshow-container {
    position: static;
    background: #f1f1f1f1;
  }
  

  .mySlides {
      
    display: none;
    padding: 80px;
    text-align: center;
  }
  
  .prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.8);
    color: white;
  }
  

  .dot-container {
    text-align: center;
    padding: 20px;
    background: #ddd;
  }

  .dot {
    cursor: pointer;
    height: 15px;
    width: 15px;
    margin: 0 2px;
    background-color: #bbb;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.6s ease;
  }
  
 
  .active, .dot:hover {
    background-color: #717171;
  }
  
  
  q {font-style: italic;}
  
  
  .author {color: darkgray;
text-align: center;}
<! DoCType html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="veiwpoint" content="width" device-width, initial-scale="1">
<link href="style.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/4510115dc1.js" crossorigin="anonymous"></script>
<title>Login</title>
<h1>Play2learn Logo</h1>
<nav>
        <li><a href="logout.html">| Log out</a> </div></li>
      
      <li class="contains"><a href="games.htlm">| Games</a>
        <ul>
          <li><a href="games:anagram-hunt.html">Anagram Hunt</a></li>
          <li><a href="games:math-facts.html">Math Facts Practice</a></li>
        </ul>
      <li> <a href="about.html"> | About</a></li>
       <li><a href="login.html">| Login</a></li>
       <li><a href="index.html">| Home</a></li>
       <li><a href="contact-us.html"> Contact</a></li>
    
    </nav>
<hr>
<form action="login.php" method="post" action="https://www.webucator.com/course-demos/htm101/process-form.cfm">
    <div class="imgcontainer">
      
    </div>
  
    <div class="container">
      <label for="uname"><b>Username</b></label>
      <input type="text" placeholder="Enter Username" name="uname" required>
  
      <label for="psw"><b>Password</b></label>
      <input type="password" placeholder="Enter Password" name="psw" required>
  
      <button type="submit">Login</button>
      <label>
        <input type="checkbox" checked="checked" name="remember"> Remember me
      </label>
     
      <form action="action_page.php">
        <div class="container">
          <h1>Register</h1>
          <p>Please fill in this form to create an account.</p>
          <hr>
      
          <label for="email"><b>Email</b></label>
          <input type="text" placeholder="Enter Email" name="email" id="email" required>
      
          <label for="psw"><b>Password</b></label>
          <input type="password" placeholder="Enter Password" name="psw" id="psw" required>
      
          <label for="psw-repeat"><b>Repeat Password</b></label>
          <input type="password" placeholder="Repeat Password" name="psw-repeat" id="psw-repeat" required>
          <hr>
      
          <p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
          <button type="submit" class="registerbtn">Register</button>
        </div>
      
        <div class="container signin">
          <p>Already have an account? <a href="login.html">Sign in</a>.</p>
        </div>
      </form>
      
      <span class="link"><a href="register.html"><label for="link"><b>Need an Account? Register</b></label></a>
       <script>
           $(function() {
          $("#refresh").click(function() {
             $("#link").load("mathgame.html")
          
        return false;
        })
        })
        </script>
   
      </div>
 </form> 
 <br />
    <form action="action_page.php">
    <div class="container">
      <h1>Register</h1>
      <p>Please fill in this form to create an account.</p>
      <hr>
  
      <label for="email"><b>Email</b></label>
      <input type="text" placeholder="Enter Email" name="email" id="email" required>
  
      <label for="psw"><b>Password</b></label>
      <input type="password" placeholder="Enter Password" name="psw" id="psw" required>
  
      <label for="psw-repeat"><b>Repeat Password</b></label>
      <input type="password" placeholder="Repeat Password" name="psw-repeat" id="psw-repeat" required>
      <hr>
  
      <p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
      <button type="submit" class="registerbtn">Register</button>
    </div>
  
    <div class="container signin">
      <p>Already have an account? <a href="login.html">Sign in</a>.</p>
    </div>
  </form>

    <form method="post" action="https://www.webucator.com/course-demos/htm101/process-form.cfm">
        <input type="hidden" name="secretcode" id="secretcode" value="42">
        <div>
    <div class="container" style="background-color:#f1f1f1">
      <button type="button" class="cancelbtn">Cancel</button>
      <span class="psw"> <a href="register.html">Forgot password?</a></span>
    </div>
  </form>
 
  <hr>
    
<footer>
  <p> &copy;2020 Play2Learn</p>
  
    <div id="footer" class="padding">
      </div>
      <link href="iconstylesheet.css" rel="stylesheet">

    <a  href="https://www.instagram.com"><i class="fab fa-instagram"></i></a>
    <a  href="https://www.facebook.com"><i class="fab fa-facebook-square"></i></a>
    <a  href="contact-us.html"><i class="fas fa-paper-plane"></i></a>
    <a  href="https://twitter.com"><i class="fab fa-twitter-square"></i></a>
</footer>
</html>

I can't figure out how to have two forms without linking to another page. I'm not sure what's wrong.

I created a login form that needs to link to a registration form without loading. When I try running the page it just shows both forms currently. I need the register form to only show when the " need an account " button is clicked and disappear when clicking the " already have account" button is clicked.

I've tried using it below, but it still seems like its reloading, and when I remove the link to another html page it doesn't work at all. I added the register form that it would link to.

  • The default behaviour for [`form`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) is submitting to the target set in `action`. If not specified it posts to itself. You set `action`multiple times in the same element. Also you can not really nest [`form`](https://stackoverflow.com/questions/379610/can-you-nest-html-forms). If you do not want to submit, [cancel it](https://stackoverflow.com/questions/4227043/how-do-i-cancel-form-submission-in-submit-button-onclick-event) or do not use `form`. – Lain Oct 26 '20 at 14:41
  • Maybe use ajax if you want to work with many forms in the same file. Or just use two forms with different submit button, then you will specify redirection for each button – Aggestor Oct 26 '20 at 14:46
  • where is the element with the of "refresh"? – epascarello Oct 26 '20 at 14:46
  • Ohh now I undestand you need the registre form to be hidden by default then when clicking "need an account " it hides the login and display the sign up form... – Aggestor Oct 26 '20 at 15:40

1 Answers1

0

You have two different containers and you want them to be interchanged on the page by clicking button.

Suppose your login container has id="login" and your your need account button has id="showSignUp", then signup with id="signup" and with id="showLogin".

Your code will look like this :

$("#showSignUp").click(()=>{
  $("#signup").show()
  $("#login").hide()
})
$("#showLogin").click(()=>{
  $("#signup").hide()
  $("#login").show()
})
<div class="container" id="login">
  <!-Your login form here--->
  <h1>Login form</h1>
  <a href="#" id="showSignUp">Need an account</a>
</div>

<div style="display:none" class="container" id="signup">
  <!-Your signup form here--->
  <h1>signUp Form</h1>
  <a href="#" id="showLogin">Already have an account</a>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Aggestor
  • 110
  • 1
  • 6