How to link to another page based on a returned value

71 Views Asked by At

I have just started using GWTBootstrap. I have set up my login page and now I want to:

  • If login was unsuccessful stay on page
  • If value returned from the database is "1" go to htmlpage1.html
  • If value returned from the database is "2" go to htmlpage2.html

In this way if the wrong login information is entered I do not go to the next page and, if successful login, people with different access levels are presented with different information.

Is there a tutorial that covers this please?

My html code is:

  <form class="form-signin">
    <h2 class="form-signin-heading">Please sign in</h2>
    <input type="text" class="input-block-level" placeholder="Email address">
    <input type="password" class="input-block-level" placeholder="Password">
    <label class="checkbox">
      <input type="checkbox" value="remember-me"> Remember me
    </label>
    <button id="SignIn" class="btn btn-large btn-primary" type="submit">Sign in</button>

    <script type="text/javascript"> 
        document.getElementById("SignIn").onclick = function () {
        location.href = "htmlpage1.html";
        };
    </script>

  </form>

</div> <!-- /container -->
1

There are 1 best solutions below

3
On

You need to create an AJAX request inside on-click method in order to get some response from a POST url, based on it, you will redirect to the correct html.

Anyway, is better to use some framework to do that.