Check Boxes and Radio Buttons Conquered by DHTML
Philip Howard writes "Pretty much every form element has been conquered by CSS so far, letting us create stylish, integrated forms to tie in closely with our site designs for that UI polish graphics artists love to have.
Radio Buttons and Check Boxes, however, have resisted most attempts to style them consistently, accessibly and elegantly- perhaps because nobody cares enough to come up with the solution.
However, these elusive form elements have finally been conquered with a simple combination of CSS and Javascript and a little HTML wrapper.
The solution is easy and quick to implement, is accessible (working with tab and space) and elegantly degrades where CSS and/or XHTML is not available."
His solution is very similar to what mine would be. I'd just walk the DOM looking for checkboxes, then replace them with some inline element creation code. His solution is to get a list of all links, then find any with a special class. He then goes on to replace the contents of the links via the innerHTML property. Clunky, but it does work.
To the author: You can achieve your goal much more easily by attaching the className to the checkbox directly. Use getElementsByTagName to get a list of INPUT tags, then loop through those. When you find one you want to replace, use the function to build the replacement tag on the fly. You can then use to swap out the tags in a hurry.
Oh, and using an anchor tag for event handling is very 1990's. Try doing something like this instead:Note that you don't actually need the "StyledCheckbox" name, because you would be passing the actual element through to the event handler.
Good luck on your work.
Javascript + Nintendo DSi = DSiCade
This is not the first time check boxes and radio buttons have been "conquered".
boo.com had quite groovy code if I remember rightly.
Suggestion to improve your version: onFocus="blur(this)"
granted i'm not exactly running the latest hardware, but every click on a radio button seemed to illicit a lot of blinking and flashing on the part of the other buttons. maybe it's just javascript running slowly as the DIVs move around or something, but i prefer to think of it as simple jealous from the other buttons in that group. "click me instead!" "no me!"
in any case, i'm all for flashy design, but this seems to be more trouble and more cumbersome than it's worth, unless that javascript can be optimized to not be so slow.
i could live a little longer in this prison
Not just that; there are usability standards. Checkboxes and radio/option buttons are supposed to look and act a certain way. It makes using them that much easier. Disguising them as something that looks like Lucky Charms marshmallows really fudges matters. The sample even had checkboxes made to look like option buttons (round).
Don't blame Durga. I voted for Centauri.
OR NOT.. using Mozilla... when I hit space it checks it and ALSO moves me to the next page!!! Not how it is suppose to work.
Firefox (Win) seems to have no trouble tabbing through them.
My results:
IE6: space and enter can't push the button
Opera8 (my primary browser): tab can't select the button.
Sheesh...
Sig erased via substitution of an identical one.
I'm using Firefox/1.0.4/Linux and I don't get the same semantics when using Javascript or not. If I'm not using Javascript (no cute inputs) I can change the state using the space bar and I can submit using Enter. But, if using Javascript spacebar moves a page down changing the input state and enter just changes the state but doesn't submit the form.
isn't this the same as what gmail uses, and that's been out for quite awhile now.
However, it renders fine in Firefox. Nevertheless, when it's not compadible with Internet Explorer, I'd hardly call this issue conquered.
For he today that sheds his blood with me shall be my brother.
This fails also in Safari - the first tabbable element on the page is the button. Shift-tabbing up from that lands me in the tab (as in tabbed-browsing) area.
Ten points for style, but minus several million for accessibility.
There is a way to do this, although it's a bit of a hack. Basically you make a separate text element, and an image for a button. You make your actual file control invisible (using opacity of 0 in all its different variants, NOT using visibility or display) and position it using CSS so that the button is over the image (it helps to use a 50% opacity for this step). Then you put javascript in the onchange event of the file box that updates the other text field so the user can see that they've selected a file (although the other text field doesn't have to post back to the server).
"Now, there's an easy way to make text bold on a webpage. Just enclose it with ! It's also backwards-compatible, showing normal text on browsers (such as Lynx) that don't support bold text." Why is this a Slashdot article? Hasn't anyone heard of webfx.eae.net?