Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  <img src="http://cdn.pcwallart.com/images/snowy-mountains-with-trees-wallpaper-1.jpg" class="ski">
  <div class="text">
      <h2>Quick Purchase</h2><br>
      <h3>Buy your ticket now for</h3>
      <h3 id="cost"></h3>
    <button type="button" class="btn btn-primary btn-lg">Buy Now</button>
    <h2>Pre-Buy Lift Tickets Here</h2><br>
    <h3>What time will you be going?</h3>
  <form name="prebuy">
    <div id="times">
      <input type="radio" name="timerange" value="morning" checked="checked"> Morning
      <input type="radio" name="timerange" value="afternoon"> Afternoon
      <input type="radio" name="timerange" value="evening"> Evening
      <h3>Resident State:</h3>
      <select id="states">
      <button type="button" class="btn btn-info btn-lg" onclick="preBuy()">Pre-Buy Now</button>
    <h3 id="preBuyPrice"></h3>
              body {
  color: black;

.ski {
  position: fixed; 
  top: 0; 
  left: 0; 
  min-width: 100%;
  min-height: 100%;
  z-index: -1;
  opacity: 0.4;
              var now = new Date();
var hour = now.getHours();

var stateList = [
  "American Samoa",
  "District of Columbia",
  "Federated States of Micronesia",
  "Marshall Islands",
  "New Hampshire",
  "New Jersey",
  "New Mexico",
  "New York",
  "North Carolina",
  "North Dakota",
  "Northern Mariana Islands",
  "Puerto Rico",
  "Rhode Island",
  "South Carolina",
  "South Dakota",
  "Virgin Island",
  "West Virginia",

//This function will allow the customer to purchase a ticket NOW without filling out any information. I mean, why pre-buy when you can buy it now like all other first-world things!
(function cost() {
  if (hour <= 12) {
    var cost = 20.0 * 0.08 + 20.0;
  } else if (hour <= 18) {
    var cost = 25.0 * 0.08 + 25.0;
  } else {
    var cost = 15.0 * 0.08 + 15.0;
  document.getElementById("cost").innerHTML = "$" + cost.toFixed(2);

//for loop over an array to populate the resident state select list
var sel = document.getElementById("states");
for (var i = 0; i < stateList.length; i++) {
  var opt = document.createElement("option");
  opt.innerHTML = stateList[i];
  opt.value = stateList[i];

//form conditionals if/else for pricing
function preBuy() {
  //store the selected Time Range
  var t = document.getElementsByName("timerange");
  var selectedTime;
  for (var i = 0; i < t.length; i++) {
    if (t[i].checked) {
      selectedTime = t[i].value;
  //store the selected State
  var e = document.getElementById("states");
  var selectedState = e.options[e.selectedIndex].value;
  //store the tax amount
  if (selectedState == "California") {
    var taxAmount = 0.06;
  } else {
    var taxAmount = 0.08;
  //conditional for figuring out and displaying the price
  if (selectedTime == "morning") {
    var preCost = 20.0 * taxAmount + 20.0;
    document.getElementById("preBuyPrice").innerHTML = "$" + preCost.toFixed(2);
  } else if (selectedTime == "afternoon") {
    var preCost = 25.0 * taxAmount + 25.0;
    document.getElementById("preBuyPrice").innerHTML = "$" + preCost.toFixed(2);
  } else if (selectedTime == "evening") {
    var preCost = 15.0 * taxAmount + 15.0;
    document.getElementById("preBuyPrice").innerHTML = "$" + preCost.toFixed(2);

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.