Im writting a code for my assigment "So,im now at view profile page when i click the button it will redirect to the update profile page when I hover the button the url is right but the button still stay at the same page" This is my code
<div class="btn-block">
<button type="button" value="back" onclick="location.href='homepage.html'">Back</button>
<?php
echo '<a href="updateprofile.php?editid='.$edit_id.'" class="edit" title="Edit" data-toggle="tooltip"><button>Apply</button></a>'
?>
</div>
I home somebody could fix this
3
Answers
It is improper to nest
a
andbutton
inside either the same or the other element. You could likely achieve a better result by using CSS to style thea
instead of relying on JavaScript to make a link from the buttons.Add
javascript:
before your javascript in theonclick
attribute like the following.See Codepen to see this working.
https://codepen.io/hiroshisan/pen/ZEqjbyQ
Instead of using
onclick="location.href='homepage.html'"
you can useonclick="window.location='homepage.html'"
. This is how I redirect using a button.