Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript: Cycle through three-state checkbox states

HTML:
<!-- Inline click handler, just for demo -->
<input type="checkbox" id="cb1" onclick="ts(this)">

JS: 
function ts(cb) { // This should show the states in the following order and cycle through them: checked, indeterminate, off.
  if (cb.readOnly) cb.checked=cb.readOnly=false;
  else if (!cb.checked) cb.readOnly=cb.indeterminate=true;
}
Source by css-tricks.com #
 
PREVIOUS NEXT
Tagged: #Cycle #checkbox #states
ADD COMMENT
Topic
Name
2+6 =