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.

                <h1>Dynamic Select Statements</h1>
  <label for="event_region">Select Region</label>
  <select id="event_region" onchange="event_postalcode(this);">
    <option value="empty">Select a Continent</option>
    <option value="Channel Islands">Channel Islands</option>
    <option value="East Midlands">East Midlands</option>
    <option value="Greater London">Greater London</option>
    <option value="Isle of Man">Isle of Man</option>
                <option value="North East">North East</option>
                <option value="North West">North West</option>
                <option value="Northern Ireland">Northern Ireland</option>
                <option value="Scotland">Scotland</option>
                <option value="South East">South East</option>
                <option value="South West">South West</option>
                <option value="Wales">Wales</option>
                <option value="West Midlands">West Midlands</option>
  <label for="county">Select a Region</label>
  <select id="event_postalcode">
    <option value="0">Select a Postalcode</option>
              var postcodeLists = new Array(4);
postcodeLists["empty"] = ["Select a Region"];
postcodeLists["Channel Islands"] = ["Please Choose", "GY", "JE"];
postcodeLists["East Midlands"] = [
  "Please Choose",
postcodeLists["Greater London"] = [
  "Please Choose",
postcodeLists["Isle of Man"] = ["Please Choose", "IM"];
postcodeLists["North East"] = [
  "Please Choose",
postcodeLists["North West"] = [
  "Please Choose",
postcodeLists["Northern Ireland"] = ["Please Choose", "BT"];
postcodeLists["Scotland"] = [
  "Please Choose",
postcodeLists["South East"] = [
  "Please Choose",
postcodeLists["South West"] = [
  "Please Choose",
postcodeLists["Wales"] = ["Please Choose", "CF", "LD", "LL", "NP", "SA", "SY"];
postcodeLists["West Midlands"] = [
  "Please Choose",
/* event_postalcode() is called from the onchange event of a select element. 
 * param selectObj - the select object which fired the on change event. 

function event_postalcode(selectObj) {
  // get the index of the selected option
  var idx = selectObj.selectedIndex;
  // get the value of the selected option
  var which = selectObj.options[idx].value;
  // use the selected option value to retrieve the list of items from the postcodeLists array
  cList = postcodeLists[which];
  // get the event_postalcode select element via its known id
  var cSelect = document.getElementById("event_postalcode");
  // remove the current options from the event_postalcode select
  var len = cSelect.options.length;
  while (cSelect.options.length > 0) {
  var newOption;
  // create new options
  for (var i = 0; i < cList.length; i++) {
    newOption = document.createElement("option");
    newOption.value = cList[i]; // assumes option string and value are the same
    newOption.text = cList[i];
    // add the new option
    try {
      cSelect.add(newOption); // this will fail in DOM browsers but is needed for IE
    } catch (e) {

🕑 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.