views:

333

answers:

3

Hi guys,

Just trying to implement these buttons at the moment: 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.

+4  A: 

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

NilColor
Thanks - I may go for this, I know it's really not ideal from a coding point of view, but maybe for the users it'll work out best.
Nick
Oh okay, one issue with this - I'm using <a href="#" onclick="document.formname.submit()"> which is okay, but throws you to the top of the page when you click it. Is there anyway to make it so that it won't jump to the top of the page? return false doesn't work cos it just stops it submitting!
Nick
try onclick="document.formname.submit();return false;"to prevent dafault onclick handler.
NilColor
Nice idea thanks, unfortunately I'm running a function when you submit the form - all a bit of a nightmare! ^_^ Going to just use input type="submit" and stick with the black border in IE6 unfortunately I think
Nick
Sorry... whats wrong with "running a function when you submit the form"? I misunderstand this... You will have your submit() running but no default onClick action on <a/> will fire (thus no scroll to top i hope ;)
NilColor
I prefer `<a href="javascript:document.formname.submit()"/>`. Less coding, no scroll to top, no returning false, *and* the users can see what the link actually does in your status bar (if you name your function appropriately anyway).
Mark
+2  A: 

I recommend the submit button, simply because that's exactly what it's there for. If you have any disabled users, the submit button will be the most meaningful button to them.

If you really don't like the border around the buttons in IE6, than you can always hide the submit button with JavaScript and then create your own button with the styles you want, whenever your home made button is clicked, then you call the submit button's onclick event handler (which will submit the form). This still allows the user to hit the enter key to submit data, and keeps the submit key in there for people who have disabled JavaScript.

MillsJROSS
+1  A: 

If you use <a> with onclick, don't forget to set role="button" and wairole="button" and also set the onkeypress handler to make the "button" accessible!

Joscha