Reputation: 93347
I have a regular form with a url as action to which the form submits when the submit button is clicked (or enter is pushed).
Now I need a second button that goes to another page. I know I should be using a link for this, but as to client's requirements, it should look like a button.
Because the CSS sheets are not made in-house (and communication is made impossible for me) I need a button in the form and thus cannot use a second form for the button.
I thought that either of the following tags could do the job:
<input type="button">
or
<button>
Can I set either of those to navigate to a link without using javascript?
Upvotes: 0
Views: 288
Reputation: 75854
You can do this with either:
A second form
Javascript
CSS to mock the appearance of a button on an anchor link
It seems you've ruled all three out in the question, but perhaps you've left a small window for inline styling (you say you have no control over the "CSS sheets" but that leaves room for a style attribute), but this solution will of course not pass any of the form info to the other page.
Upvotes: 2
Reputation: 8343
It can't be done in pure HTML.
Edit: Excepting, of course, Peter's Method
Upvotes: 0
Reputation: 17344
The only way to do this without using JavaScript is to have the second button inside a second form, whose action is the desired destination. You may be able to use CSS to position this second button 'inside' the first form.
Upvotes: 4
Reputation: 2109
change the form's action dynamically:
here is javascript code:
function submitAnotherURL(){
var yourForm = document.your_form_name;
yourForm.action='your_other_link';
yourForm.submit();
}
the button in html:
<input type="button" onclick="submitAnotherURL()" value="Click here"/>
Upvotes: 0
Reputation: 1638
no you must use javascript
<input type="button" value="go" onclick="javascript:location.href='http://www.stackoverflow.com';" />
Upvotes: 1
Reputation: 279
<input type="button" onclick="document.location='my_other_link'" value="Click here"/>
Upvotes: 0