Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
    <link href="css/elements.css" rel="stylesheet">
    <script src="js/my_js.js"></script>

    
    <center>
      <h2>Set Alarm</h2>
        <label class="cb cross">
        <input id="cb0" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Sun</span>
      </label>
      <label class="cb cross">
        <input id="cb1" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Mon</span>
      </label>
      <label class="cb cross">
        <input id="cb2" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Tue</span>
      </label>
      <label class="cb cross">
        <input id="cb3" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Wed</span>
      </label>
      <label class="cb cross">
        <input id="cb4" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Thu</span>
      </label>
      <label class="cb cross">
        <input id="cb5" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Fri</span>
      </label>
      <label class="cb cross">
        <input id="cb6" type="checkbox" />
          <span class="cb-field"></span>
          <span class="cb-text">Sat</span>
      </label><br>
    <div id="pick-inline" type="text"></div>
      <script>
        window.addEventListener("load", function() {
          tpick.attach("pick-inline");
        });
      </script>
    
      
    
   
    
    <input type="button" id="submit" value="Submit" formmethod="post" onclick="myFunction()">
    </form>
    <script>
      function myFunction() {
        document.getElementById("myForm").clear();
      }
    </script>
  
              
            
!

CSS

              
                @import "https://fonts.googleapis.com/css?family=Orbitron";

span {
  text-align: center;
  color: red;
  font-weight: 600;
  padding: 0 auto;
}

/* [CONTAINER] */
.tpicker {
  padding: 10px;
  width: 30%;
  max-width: 250px;
  white-space: nowrap;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  margin: auto;
}

/* [HR + MIN + AM/PM + DAY] */
.tpicker-h, .tpicker-m, .tpicker-ap, .tpicker-d {
  display: inline-block;
  width: 20%;
}

.tpicker input[type=text] {
  box-sizing: border-box;
  width: 95%;
  padding: 5px;
  margin: 5px 0;
  border: 2px solid gray;
  border-radius: 50%;
  background: #fff;
  color: #000;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.tpicker-up, .tpicker-down {
  text-align: center;
  color: #ff0000;
  cursor: pointer;
}
              
            
!

JS

              
                

// Time Picker
var tpick = {
  attach : function (container, target) {
  // attach() : attach time picker to target

    // Generate a unique random ID for the time picker
    var uniqueID = 0;
    while (document.getElementById("tpick-" + uniqueID) != null) {
      uniqueID = Math.floor(Math.random() * (100 - 2)) + 1;
    }

    // Create new time picker
    var tp = document.createElement("div");
    tp.id = "tpick-" + uniqueID;
    tp.dataset.target = target;
    tp.classList.add("tpicker");

    // Create hour picker
    tp.appendChild(this.draw("h"));
    tp.appendChild(this.draw("m"));
    tp.appendChild(this.draw("ap"));
    tp.appendChild(this.draw("d"));
    
    // Attach time picker to target container
    document.getElementById(container).appendChild(tp);
  },

  draw : function (type) {
  // draw() : support function to create the hr, min, am/pm selector

    // Create the controls
    var docket = document.createElement("div"),
        up = document.createElement("div"),
        down = document.createElement("div"),
        text = document.createElement("input");
    docket.classList.add("tpicker-" + type);
    up.classList.add("tpicker-up");
    down.classList.add("tpicker-down");
    up.innerHTML = "&#65087;";
    down.innerHTML = "&#65088;";
    text.readOnly = true;
    text.setAttribute("type", "text");

    // Default values + click event
    // You can do your own modifications here
    if (type=="h") { 
      text.value = "06"; 
      up.addEventListener("click", function(){ tpick.spin("h", 1, this); });
      down.addEventListener("click", function(){ tpick.spin("h", 0, this); });
    } else if (type=="m") { 
      text.value = "30";
      up.addEventListener("click", function(){ tpick.spin("m", 1, this); });
      down.addEventListener("click", function(){ tpick.spin("m", 0, this); });
    } else if (type=="ap") {
      text.value = "AM";
      up.addEventListener("click", function(){ tpick.spin("ap", 1, this); });
      down.addEventListener("click", function(){ tpick.spin("ap", 0, this); });
    } else if (type=="d") { 
      text.value = "Su";
      up.addEventListener("click", function(){ tpick.spin("d", 1, this); });
      down.addEventListener("click", function(){ tpick.spin("d", 0, this); });

    // Complete + return the docket
    docket.appendChild(up);
    docket.appendChild(text);
    docket.appendChild(down);
    return docket;
  },

  spin : function (type, direction, el) {
  // spin() : when the up/down button is pressed

    // Get current field + value
    var parent = el.parentElement,
        field = parent.getElementsByTagName("input")[0],
        value = field.value;

    // Spin it
    if (type=="h") {
      value = parseInt(value);
      if (direction) { value++; } else { value--; }
      if (value==0) { value = 12; }
      else if (value>12) { value = 1; }
    } else if (type=="m") {
      value = parseInt(value);
      if (direction) { value+=5; } else { value-=5; }
      if (value<0) { value = 55; }
      else if (value>60) { value = 0; }
      if (value<10) { value = "0" + value; }
    }
    else if (type=="ap") {
      value = value=="PM" ? "AM" : "PM";
    }
    else if (type=="d") {
      value = value=="Su" ? "Mo" ? "Tu" ? "We" ? "Th" ? "Fr" ? "Sa" : "Su"; 
    }
    field.value = value;
  },

  // set() : set the selected time on the target
  set : function (el) {

    // Get the parent container
    var parent = el.parentElement;
    while (parent.classList.contains("tpicker") == false) {
      parent = parent.parentElement;
    }

    // Formulate + set selected time
    var input = parent.querySelectorAll("input[type=text]");
    var time = input[0].value + ":" + input[1].value + " " + input[2].value;
    document.getElementById(parent.dataset.target).value = time;
  },
  
};

  
              
            
!
999px

Console