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)"
Will Lynx render them correctly with ascii-art?
"A door is what a dog is perpetually on the wrong side of" - Ogden Nash
This occupation won't stand! You may think you can apply your western styles upon us by force, but history will prove you wrong.
[ ] This is a good idea
[ ] This is a kludge
[ ] I didn't read TFA, but I like clicking boxes anyway
Is it a good thing to have controls that deviate from the standard so much that they aren't even recognizable anyore, like the green/grey round toggle button that replaces the checkbox on the sample page? Why disguise standard controls so the user will have to spend some time trying to find out what the standard controls are "hidden as"?
Don't blame Durga. I voted for Centauri.
I just hope the marketing people that work in my company aren't reading Slashdot today.
Otherwise, I'll be making fancy checkboxes for the next 2 months.
Damn you, Slashdot.
I'm a big tall mofo.
Do editors not read articles any more? shit.
The examples look very nice. I still think the bigger problem is that web applications have absolutely no UI consistency between them, though. On one web site, select-boxes cause a form to be immediately submitted when a selection is made; on others, you have to click "Go." On one web site, check boxes look like boxes with check marks; on another they look like stars; on another they look like glowing orbs (not very colorblind-friendly).
This is the sort of thinking that leads to such UI atrocities as Winamp, iTunes for Windows, and Firefox for Mac OS X: all three of these ignore most of the native widget drawing capability in the name of creating a pointlessly slick, cross-OS-consistent experience.
I for one welcome the arrival of XAML and XUL: ways to describe forms that every OS will render using its own navigation and widget capabilities. It'll be as awesome as the time Java solved that problem for everyone everywhere.
For more information, click here.
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
I would prefer to have normally and familiar elements that i can tab through than fancy graphics that don't work as expected.
Hey, here's a question-- Why do we [i]need[/i] styled checkboxes? I hear those words and I just get this mental image of style kicking contents in the nads over and over and over.
Not to mention - but it seems nobody really cares about this, and apparently bringing the subject up always generates a deluge of "we won't hold browser technologies back because of *this*" answers - web developers are so busy beautifying web pages and turning everything graphical and snazzy that you can always count on one category of people getting screwed with this trend: blind people.
They are the truly forgotten of this embelishment, and java[script]tization of the net. I wish web developers cared more about (1) complying strictly with W3C recommendations for accessibility and (2) not forgoing accessibility just for beauty...
"A door is what a dog is perpetually on the wrong side of" - Ogden Nash
The author should apply for a patent for this. I'm sure it'd be approved.
There are certainly some people out there who are impressed by cool graphic tricks.
After writing web applications for ten years, though, I find that more and more people simply want to get the job done. Perhaps it's that I work in Healthcare and my customers are busy people caring for patients.
The other thing that makes me nervous about bells and whistles is that they add complexity to things. Complicated things break. Browser makers have changed how they implement CSS and DHTML before and there's a good chance they'll change it in the future. Basic support for checkboxes will last another fifty years.
They look horrible and confusing to me, especially in the example the author has given. If i had come across that form on a page and it said "please select a rating" or the like I would be momentarily confused.
I think there is a good reason why radio buttons and check boxes haven't been styled too much - it's because they are perfect the way they are.
If you want to style a checkbox or radio button atleast make it look like one, get some inspiration from the likes of Opera skins.
I am very glad it degrades well, but javascript is never a solution. The goal of any web developer worth his salt is to make something universally compatible, intuitive, functional, AND good looking regardless of extensions or security settings.
It's a nice hack admittedly. Heck I may even use it on personal sites.
A lot of people seem to be missing the bigger point here. It's not that he's replacing checkboxes with images, it's that he's managing to do it while keeping the page properly structured and accessible to all browsers. While the page isn't quite all the best HTML underneath (what's with the tables?), if you look at the forms, it's proper HTML and not some javascript hack that will break old browsers.
I think that's the point, anyway.
Slashdot: 24 hours behind every other site or your money back!
Accessibility my arse.
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.
Javascript is dangerous, not standardized, and crap.
Javascript isn't necessarily crap if used correctly. However, the only times I get to "experience" it are when websites want to do something stupidly useless, like resizing windows or goofing with the mouse pointer, or bury me in multiple cascading popups.
So, I don't know if it's really dangerous or not standardized, but it's definitely annoying and therefore I turned it off, and I don't go to sites that insist on using it.
Find another alternative please.
Flash? same problem, it's annoying (and CPU-intensive).
"A door is what a dog is perpetually on the wrong side of" - Ogden Nash
Tab works, but Space does nothing (or in Firefox (Deer Park Alpha 1), it scrolls the page down as normal). IE6 has the same problem plus the icons flicker horribly when moused over. maybe i'm missing something?
This is my Sig, this is my Gun. One is for Slashdot and one is for Fun.
This looks nice but, as many seem to forget about, the keyboard functionaility (eg: Tab then Spacebar to select) just isn't there. I have several users that still don't feel comfortable with a mouse.
Definetely a slow news day on Slashdot today. What will they report next? Seeing the back of your head finally possible thanks to an ingenious mirror system. Sheeesh.
Yes using images as form elements can work. Integrating them server side is difficult.
Though my real beef: every mouse over causes a *flicker* of the image.
End users don't like "wierd" behavior in user interfaces. There is no reason that the image should disappear and re-appear when the mouse goes over the image. This behavior gets worse as the connection speed of the user decreases.
This sort of behavior makes people who are not fully comfortable with the computer uncomfortable reducing their desire to interact with an application that behaves in this manner.
The flicker bahavior has also become rampant in drop down menu and site navigation everywhere. Back in the day we used to cache images but now we just accept sub-standard UI behavior because caching images "is a pain".
My 2 cents
isn't this the same as what gmail uses, and that's been out for quite awhile now.
"[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz
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.
It makes it easier for the people writing the forum software to be able to parse out HTML tags and force the use of tags in a different format in order to control what posters can do in their posts; they can strip out all HTML tags, rather than making the parser smart enough to be able to identify malicious or subcompetent HTML coding. Of course, you then wind up with making people switch between thinking in HTML tags and thinking in your tag format. But if the rest of your functionality is good enough, people will use it -- and the ones who are good enough to be writing HTML directly into a text editor should be good enough to make the mental switch.
And, of course, if you don't bother to preview your post and actually look at it to make sure it looks like you think it should, then you deserve to look silly if you screwed something up.
One of the most fundamental concepts of good UI/GUI design is that you DON'T INTRODUCE NEW THINGS.
Everytime you introduce something new the user has to learn how to use it or what the fuck it is. This is bad. Really bad. You just won't believe how vastly, staggeringly, jaw-droppingly bad it is.
It may seem incredibly anal, stale and anti-progressive but that's the whole point. There's no such thing as an innovative interface because innovation has connotations of something both new and better. In the realm of Human Computer Interaction (HCI) new and better are mutually exclusive. Good UIs are simple, intuitive and introduce absolutely nothing new. Ever.
There are only two truly intuitive interfaces in existance. The nipple and the vagina. The rest you have to learn how to use.
Save the styled checkboxes and radio buttons for other people in your yuppie coffee house. Your average user doesn't want them, won't understand them, won't appreciate them and doesn't care what they look like.
Question everything
We still don't have semi-standard editable grid and collapsable tree/outline widgets, and you guys are fussing about pretty borders around checkboxes? Pardon me for my outburst, but you are a bunch of fucken girlie men!
Let's resolve the practical issues first, and THEN focus on pretty frilly borders.
Table-ized A.I.
"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?