git @ Cat's Eye Technologies DAM / master demo / checkbox.html
master

Tree @master (Download .tar.gz)

checkbox.html @masterraw · history · blame

<!DOCTYPE html>
<!--
SPDX-FileCopyrightText: In 2019, Chris Pressey, the original author of this work, placed it into the public domain.
For more information, please refer to <https://unlicense.org/>
SPDX-License-Identifier: Unlicense
-->
<head>
  <meta charset="utf-8">
  <title>DAM checkbox demo</title>
</head>
<body>

<h1>DAM checkbox demo</h1>

<p>DAM comes with a checkbox widget.  This widget simply bundles together a checkbox input
(on the left) with a label (on the right).</p>

<div id="installation"></div>

<script src="../dist/dam-plus-widgets-0.2.js"></script>
<script>
  var div=DAM.maker('div'), span=DAM.maker('span');
  var understood = false;
  var great = false;
  var statusBar = span();
  function updateStatus() {
    statusBar.textContent = (understood ? "understood " : "") + (great ? "great " : "");
  }
  var d = div(
    div(
      DAM.makeCheckbox({ onchange: function(b) { understood = b; updateStatus(); } }, "I understand"),
      DAM.makeCheckbox({ onchange: function(b) { great = b; updateStatus(); } }, "It's great")
    ),
    statusBar
  );
  document.getElementById('installation').appendChild(d);
</script>

</body>