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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div>
  <img src="http://cdn.pcwallart.com/images/snowy-mountains-with-trees-wallpaper-1.jpg" class="ski">
  <div class="text">
    <div>
      <h2>Quick Purchase</h2><br>
      <h3>Buy your ticket now for</h3>
      <h3 id="cost"></h3>
    </div><br>
    <button type="button" class="btn btn-primary btn-lg">Buy Now</button>
  </div>
  <hr>
  <div>
    <h2>Pre-Buy Lift Tickets Here</h2><br>
    <h3>What time will you be going?</h3>
  </div>
  <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
    </div>
    <br><br>
    <div>
      <h3>Resident State:</h3>
      <select id="states">
    </select>
    </div><br><br>
    <div>
      <button type="button" class="btn btn-info btn-lg" onclick="preBuy()">Pre-Buy Now</button>
    </div><br>
    <h3 id="preBuyPrice"></h3>
  </form>
</div>
              
            
!

CSS

              
                body {
  text-align:center;
  color: black;
}

.ski {
  position: fixed; 
  top: 0; 
  left: 0; 
  min-width: 100%;
  min-height: 100%;
  z-index: -1;
  opacity: 0.4;
}
              
            
!

JS

              
                var now = new Date();
var hour = now.getHours();

var stateList = [
  "California",
  "Alabama",
  "Alaska",
  "American Samoa",
  "Arizona",
  "Arkansas",
  "Colorado",
  "Connecticut",
  "Delaware",
  "District of Columbia",
  "Federated States of Micronesia",
  "Florida",
  "Georgia",
  "Guam",
  "Hawaii",
  "Idaho",
  "Illinois",
  "Indiana",
  "Iowa",
  "Kansas",
  "Kentucky",
  "Louisiana",
  "Maine",
  "Marshall Islands",
  "Maryland",
  "Massachusetts",
  "Michigan",
  "Minnesota",
  "Mississippi",
  "Missouri",
  "Montana",
  "Nebraska",
  "Nevada",
  "New Hampshire",
  "New Jersey",
  "New Mexico",
  "New York",
  "North Carolina",
  "North Dakota",
  "Northern Mariana Islands",
  "Ohio",
  "Oklahoma",
  "Oregon",
  "Palau",
  "Pennsylvania",
  "Puerto Rico",
  "Rhode Island",
  "South Carolina",
  "South Dakota",
  "Tennessee",
  "Texas",
  "Utah",
  "Vermont",
  "Virgin Island",
  "Virginia",
  "Washington",
  "West Virginia",
  "Wisconsin",
  "Wyoming"
];

//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];
  sel.appendChild(opt);
}

//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);
  }
}

              
            
!
999px

Console