Check All

This script checks all of the checkboxes on a form with Ctrl-LogoClick

HTML

<body onload="prep_form();">
<form name="SGMC_commonlabs" >
    
  <div id="topBanner">
    <table class="banner" width=100%>
      <tr>
        <td class="noHL"><img src="http://i209.photobucket.com/albums/bb128/JDangerously42/sgmc.jpg" width="320" height="52" id="logo"/></td>
        <td class="noHL" align="center">Common Labs</td>
      </tr>
    </table>
  </div>
    
  <table style="border: #636d76 solid;" id="demographics" width=100%>
    <tr>
      <td class="demographics noHL" align="center">@@patient.name@@ - @@patient.unit@@</td>
    </tr>
  </table>
    
  <div id="tabs"> <!-- ########## Begin Tabbed Area  ##########-->

    <ul id="nav">
      <li><a href="#tabs-A" onclick="this.innerHTML=' Routine &nbsp;&nbsp;<font size=1 color=red><sup>viewed</sup></font>'">Routine</a></li>
      <li><a href="#tabs-B" onclick="this.innerHTML=' In AM (4AM) &nbsp;&nbsp;<font size=1 color=red><sup>viewed</sup></font>'">In AM (4AM)</a></li>
      <li><a href="#tabs-F" onclick="this.innerHTML=' Recent Labs <font size=1 color=red><sup>viewed</sup></font>'">Recent Labs</a></li>
    </ul>
      
      <div id="tabs-A"><!--##### Begin Tab 1 Routine ########-->
        <table class="grid" border="0" cellspacing="0" cellpadding="0" style="border:2px solid #006633" bgcolor="#CCBFA3"; id="my_table" width=100%>
          <tr>
            <th>&nbsp;&nbsp;&nbsp;&nbsp;Hematology </th>
            <th>Chemistry </th>
          </tr>
          <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="checkbox" name="lab_hema2_CB3" id="lab_hema2_CB3" value="true" />
              CBC with Auto Diff</td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="checkbox" name="NC_lab_cult1_CB3" id="NC_lab_cult1_CB3" value="true" />
              Blood Culture x2
              &nbsp;&nbsp;
              <select name="BloodCulFreq3" id="BloodCulFreq3">
                <option value="Q15MIN">Q15MIN</option>
               ...

CSS

body{
 background-color:#D1D1D1; 
 font-family: Trebuchet MS, Helvetica, Arial, sans-serif; 
 font-size: 62.5%; 
 margin: 30px;
}
table.banner {
 border: #006633 solid;
 background-color: white; 
 width: 100%; 
 color: #006633;
 font-family: Tahoma, Verdana, sans-serif;
 font-weight: bold;
 text-shadow:1px 1px 1px #fff;
}
td{
 text-align:left;
 font-family: Tahoma, Verdana, sans serif;
 font-size: 10pt;
 vertical-align:top;
}
table#banner td{
 background-color: white;
 width: 50%;
 font-size: 18pt;
}
table#demographics td{
 FONT-SIZE: 9pt;
 COLOR: #000000;
 FONT-FAMILY: Tahoma, Verdana, sans-serif;
}
table.control {
 border: #006633 solid;
 background-color: white;
 height: 25pt;
}
th{
 border-top: #006633 solid 1pt;
 border-bottom: #006633 solid 1pt;
 background-color: #FFF6E3;
 padding-left: 12px;
 text-align:left;
 font-family: Tahoma, Verdana, sans serif;
 color: green;
 font-weight: bold;
 font-size: 10pt;
 line-height: 15pt;
 vertical-align:top;
}

td.hover { background-color: #FFFF99; }
td.selected { background-color: yellow;}
td.checked { background: yellow; }
td.urgent { background: #FF33CC; }
td.alert{ color:#fff; background-color:#FF3300; font-weight:bold; }
td.safe{ background-color:#66FF66; font-weight:bold; }


div.hide{ display:none; }
div.show{ display:inline; vertical-align:middle;}

select.hide{ display:none; }
select.alert{ color:#fff; background-color:#FF3300; font-weight:bold; }
select.safe{ background-color:#66FF66; font-weight:bold; }




/*Tabs*/
.ui-tabs { position: relative; padding: .2em; zoom: 1; } 
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; }
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; }
.ui-tabs .ui-tabs-nav...

JavaScript

var check=1;

//preps the horizontal tabs
$("#tabs").tabs();

//fires check all upon ctr clicking the logo
$('#logo').on('click',function(e) { if (e.ctrlKey) { checkAll(); }});

//Highlighter
$("input:checkbox").click(function() {
    if ($(this).hasClass('parent')) {}
    else{
        $(this).parent("td").toggleClass("checked");
    }
});

// Changes td color on hover unless td has the noHL class
$("td").hover(function() {
    if ($(this).hasClass('noHL')) {}
    else{
        $(this).toggleClass("hover");
    }
});

//prevents checking the box when clicking the dropdown 
$('td select').click(function(event) {
    event.stopPropagation();
});

// allows for clicking anywhere in the td to check the checkbox
$("td").click(function(e) {
    if ($(this).hasClass('noHL')) {}
    else{
        var chk = $(this).closest("td").find("input:checkbox").get(0);
        if(e.target != chk){chk.click()}
    }
});

//Check All checkboxes
function checkAll(){
    if (check==1) {
        $('input:checkbox').attr('checked', true);    
        check=0
    }
    else if (check==0){
        $('input:checkbox').attr('checked', false);    
        check=1        
    }
};

//Prompt confirmation for exit without orders
function confirmExit()
{
    var agree=confirm("Are you sure you wish to exit WITHOUT placing orders?");
    if (agree)
        return "true" ;
    else
        return false ;
}

//Prompt confirmation for restart
function confirmRestart()
{
    var agree=confirm("Are you sure you wish to RESTART the form?");
    if (agree)
        return true ;
    else
        return false ;
}