Reputation:
I want to know how do i put link on input button in html pages. As of now i am trying to make a link on input button by putting hyperlinks around buttons but can it be possible with any other method to navigate to another page?
curretly i am doing like this:
<html>
<head>
<title>Practise 20</title>
<style>
input[type="submit"]{border:none; background:#000; color:#fff}
</style>
<body>
Click on Button to navigate the Pages
<form>
<a href="http://www.google.com" target="self"><input type="submit" Value="Go"></a>
</form>
</body>
</html>
Upvotes: 4
Views: 73762
Reputation: 1
<a href="http://www.google.com" target="self"><input type="submit" Value="Go"></a>
Very simple! Just put some bootstrap classes into it and add role as button. That's it!
<a class="btn btn-success" role="button" href="http://www.google.com" target="self"><input type="submit" Value="Go"></a>
Upvotes: -1
Reputation: 499
You can definitely do this. You can have a form with a post action to the route, then use bootstrap classes to disguise the input as a nav link
<form action="/Rooms/Edit/:id" method="POST" style="margin: 0 1rem;">
<input class="btn btn-link" value="Edit Rooms" type="submit" style="font-weight: bold; text-dectoration:none">
</form>
Upvotes: 0
Reputation: 11
Attribute formaction works pretty well. Here is an example:
<input type="submit" formaction="login.html" value="Submit to another page">
Upvotes: 1
Reputation: 995
you can put link on input buttons by java script.. try like this
<html>
<head>
<title>Practise 20</title>
<style>
input[type="submit"]{border:none; background:#000; color:#fff}
</style>
</head>
<body>
Click on Button to navigate the Pages
<form>
<input onClick="window.location.href='put your page url here'" type="submit" Value="Go">
</form>
</body>
</html>
Upvotes: 7
Reputation: 1876
<form action="http://www.google.com"><input type="submit" Value="Go"></form>
Please note that you should not use submit buttons for hyperlinking purpose. Submit button is for submitting a form, therefore linking it to a page send the wrong info to the user. Still you can do it; if you need to.
Upvotes: 0
Reputation: 944568
I want to know how do i put link on input button in html pages?
You don't. Links are links. Buttons are buttons. One cannot be placed inside the other in HTML.
If you want a link that looks like a button, then use a link and apply CSS to make it look the way you want.
Upvotes: 0
Reputation: 691
You might get it to work better with a simple javascript.
<script type="text/javascript">
function google() {
window.location = "http://google.com";
}
</script>
And as of the HTML part:
<input type="submit" value="Go" onClick="google()">
Upvotes: 1