A clever way of writing multiple choice boxes for forms in jquery, jquery forms
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Radio statement:
$(function(){ $("tbody>tr:odd").addClass("odd"); $("tbody>tr:even").addClass("even"); $('tbody>tr').click(function(){ $(this).addClass('selected').siblings().removeClass('selected').end().find(':radio').attr('checked', true); });// $('table :radio:checked').parent().parent().addClass('selected'); $('table :radio:checked').parents("tr").addClass('selected');//$('tbody>tr:has(:checked)').addClass('selected');})
Checkbox Syntax:
$(function(){ $("tbody>tr:odd").addClass("odd"); $("tbody>tr:even").addClass("even"); $('tbody>tr').click(function(){ if($(this).hasClass('selected')){ $(this).removeClass('selected').find(':checkbox').attr('checked', false); }else{ $(this).addClass('selected').find(':checkbox').attr('checked', true); } });// $('table :checkbox:checked').parent().parent().addClass('selected'); $('table :checkbox:checked').parents("tr").addClass('selected'); //$('tbody>tr:has(:checked)').addClass('selected');})