I want to select multiple rows in a table without using a checkbox. Is there any way to do this?
2 Answers
If it's just visually select you're after, it's very possible with Javascript and CSS.
Using jQuery, or some other JS library, you can add a HTML class to the row on click. Then use CSS to style that class.
jQuery:
$('tr').click(function(){ $(this).toggleClass('selected'); });
CSS:
tr.selected { background: #ccc; }
4 Comments
John Parker
Of course, there's no reason why you couldn't back this with a hidden field that effectively emulated a checkbox from the form processor's perspective. That said, graceful degradation would be an issue. :-)
Lightness Races in Orbit
@middapark: "why you couldn't"* presumably :)
John Parker
@Tomalak Geret'kal Yup. Fixified. Ta for the heads up. :-)
Markus Hedlund
Yes, but I wouldn't bother hiding the checkbox. This solution should really be an extension of the checkbox, for 508 compliance at least.