Home » Javascript » link button to another page

link button to another page

Posted by: admin August 12, 2018 Leave a comment

Questions:

I know there a lot of things related to this stuff but I find it quite hard to implement

My current result is this. I added some details to the code to add to the DB then as I pressed the next button, it goes to another same page but its all about update and its not going anywhere to the page that I linked it to.

So far, this is what I’ve made to link the button to another page

         if(!employeeExist){
                $("#nextBtn").html("Next");
                $("#nextBtn").removeClass("btn-success")
                $("#nextBtn").addClass("btn-primary")
                $('#a').hide();
                $('#c').hide();
                $('#d').hide();
                $("#updateBtn").hide();
            }else{
                $("#updateBtn").html("Update");
                $("#updateBtn").removeClass("btn-primary")
                $("#updateBtn").addClass("btn-success")
                $('#a').show();
                $('#c').show();
                $('#d').show();
                $("#nextBtn").hide();
            }
            $("#updateBtn").click(updateCompanyInfo);
            $("#nextBtn").click(updateCompanyInfo);

and this

if(employeeExist) {
   $alertDiv("success","Company related information was successfully updated.",true);
    } else {
   $alertDiv("success","Company related information was successfully added.",true);
    var fam = "${pageContext.request.contextPath}/employee/details/family?id="+empID;
    window.location.replace(fam);
}

Here is the redirect part of my code

    function Redirect() {
           window.location="${pageContext.request.contextPath}/employee/details/family?id="+empID;
        }

and the HTML part

<!-- Update -->
<div class="col-md-2 col-md-offset-8">
  <br>
  <div class="input-group">
    <span class="input-group-btn">
			<button id = "updateBtn" class="btn btn-success marginBtn">Update</button>
					</span>
  </div>
  <br>
</div>
<!-- Next -->
<div class="col-md-2 col-md-offset-7">
  <br>
  <div class="input-group">
    <span class="input-group-btn">
			<button id = "nextBtn" class="btn btn-primary marginBtn" onclick="Redirect();">Next</button>
						</span>
  </div>
  <br>
</div>
Answers: