doubledee — 2012-05-20T03:40:05-04:00 — #1
Is it possible to take this Form Submit Button...
<input id="createPM" type="submit" name="createPM" class="" value="Create PM"/>
... and make it so that when I click on it, it goes to another page (e.g. "create_pm.php") like a hyperlink would do?
(With the key point being that I do NOT want the default, silver/grey/metallic look to change...)
ralphm — 2012-05-20T03:47:43-04:00 — #2
It's a form element, not a hyperlink. Best to use the right tool for the job.
chris_upjohn — 2012-05-20T08:42:48-04:00 — #3
<button onclick="window.location='http://www.google.com'; return false;">Click Me</button>
ralphm — 2012-05-20T09:15:13-04:00 — #4
Not a great option for anyone with JS off, though ... It's easy enough to style an anchor to look the same, although default forms elements don't look the same cross browser, so you'd want to style links and form buttons the same way, I guess.
doubledee — 2012-05-20T14:43:32-04:00 — #5
There is no sin in wanting people to click on a Button to go to somewhere else on your site than a link...
And Paul O' showed me how to do that using a background image slice to create the illusion of a Button, however, I would like it to have the default silver/gray/metallic look, so that is what I'm asking.
Also, Ralph, what I am trying to do is logical, because I want a "Send PM" Button on my "inbox.php" page to take them to my "create_pm.php" script which is a Form...
That is the whole point...
It is more intuitive to click on a metallic looking "Send PM" Button in a User's Inbox, and then be taken to a Form to do just that, versus clicking on a hyperlink.
Yahoo Mail does that exact thing...
doubledee — 2012-05-20T15:06:47-04:00 — #6
Here is a partial screen-shot of my Inbox...
As mentioned before, I think having a metallic Button for "Create PM" is more consistent with my "Go" Button to the left, versus having a Create PM hyperlink...
Because, the entire area is encapsulated in an HTML Form, I could leave things as a Form Button and use a Redirect to take the User to my "create_pm.php" script, but I was hoping to make things function like a hyperlink while look like a Form Button... :-/
ralphm — 2012-05-20T19:36:37-04:00 — #7
I don't know if this is really a proper use of the form element, but you could try doing it like this:
<form action="http://sitepoint.com/" method="post">
<input type="submit" value="Let's Go!">
You have to use the whole <form> element, rather than just an input.
doubledee — 2012-05-20T21:53:27-04:00 — #8
As far as I can tell, there is nothing wrong with having several Submit Buttons in a Form and having Redirects behind some of them...
What I have works, and it looks like I want it to as well.
stomme_poes — 2012-05-21T04:44:28-04:00 — #9
If the form's action attribute is a URL and the method is a GET rather than a POST, hitting a submit button will send the user to the new URL.
ralphm — 2012-05-21T05:00:25-04:00 — #10
Seems to work with POST too.
aufshebung — 2012-05-21T20:38:03-04:00 — #11
Couldn't you just put the button inside an <a> and get the best of both worlds?
<input type="button" value="Google!" />
ralphm — 2012-05-21T20:42:47-04:00 — #12
It doesn't validate, so even if it works, it's probably best avoided.