Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

button vs input type="submit" vs a onclick="document.formname.submit()"

Just trying to implement these buttons at the moment: http://web.archive.org/web/20110721191046/http://particletree.com/features/rediscovering-the-button-element/

Can't decide which to go for, since here we mostly use IE6. As far as I can tell...

button:

  • Lets you submit the form as usual (ie hitting enter on the form), lets you disable it, standards compliant, doesn't rely on javascript
  • No :hover in IE6 without using Suckerfish, but you can't then style it accordingly and are limited to just one background color & has a horrible black border in IE6

input type="submit":

  • Also let's you submit the form as usual
  • Can't include images so you'll have a silly amount of class files for what I need, and again no :hover in IE6 without Suckerfish

a onclick="document.formname.submit()"

  • Easy to style in IE6 without any hacks
  • Not so easy to work with, without hacks! ie you can't submit the button with the enter key

... so I'm just wondering, of the three, which one is generally preferred? Ideally I guess I want function over style, but it is a requirement to have Javascript enabled here (it's only for an intranet page) and I guess generally people don't mind too much what's going on in the background? Hmm.

like image 991
Nick Avatar asked Nov 25 '09 09:11

Nick


1 Answers

Go for onclick="document.formname.submit()" route for style and add hidden button for functionality.

like image 70
NilColor Avatar answered Sep 25 '22 03:09

NilColor