Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


                <script src=""></script>
<script src=""></script>
<script src=""></script>
<form id="user_form">

  <div class="option-group">
    <h2>Select US States</h2>
    <div id="usa" class="mapdiv"></div>
    <input type="hidden" name="usa" id="usa_field" value="" />
  <div class="option-group">
    <h2>Select Canadian Provinces</h2>
    <div id="canada" class="mapdiv"></div>
    <input type="hidden" name="canada" id="canada_field" value="" />
  <div class="option-group">
    <h2>Other options</h2>
    <p><input type="text" name="name" value="" placeholder="Your first name" /></p>
    <p><input type="text" name="surname" value="" placeholder="Your last name" /></p>
    <p><label><input type="checkbox" name="option1" value="1" /> Option #1</label></p>
    <p><label><input type="checkbox" name="option1" value="2" /> Option #2</label></p>
    <p><label><input type="checkbox" name="option1" value="3" /> Option #3</label></p>
    <p><input type="submit" value="Submit" onclick="return handleFormSubmit();" />
  <div class="option-group">
    <h2>Form data debug</h2>
    <div id="form-debug">Once you select some options, click "Submit" to see form data here</div>


                .mapdiv {
	width	: 250px;
	height	: 220px;
.option-group {
  float: left;
  overflow: auto;
  font-family: Verdana;
  font-size: 14px;
  margin-right: 20px;
  max-width: 250px;
.option-group h2 {
  color: #555;
  font-weight: 500;
  font-size: 17px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 10px;
  margin-bottom: 10px;
#form-debug {
  font-size: 12px;


 * AmCharts.ready function handler is executed when the page loads
 * We are going to create both maps then. We'll store references to
 * all maps we create in the global maps variable so that we can
 * come back and get info from them later.
var maps = {};
AmCharts.ready(function() {

 * Creates a country map
 * $param country A map and container id
function createMap (country) {
    var map = new AmCharts.AmMap();
    maps[country] = map;
    map.panEventsEnabled = true;
    map.backgroundColor = "#666666";
    map.backgroundAlpha = 1;
    map.zoomControl.panControlEnabled = false;
    map.zoomControl.zoomControlEnabled = true;
    var dataProvider = {
    map: country + "Low",
        getAreasFromMap: true
    map.dataProvider = dataProvider;
    map.areasSettings = {
        autoZoom: false,
        color: "#CDCDCD",
        colorSolid: "#5EB7DE",
        selectedColor: "#5EB7DE",
        outlineColor: "#666666",
        rollOverColor: "#88CAE7",
        rollOverOutlineColor: "#FFFFFF",
        selectable: true
    map.addListener('clickMapObject', function (event) {
        // deselect the area by assigning all of the dataProvider as selected object
        map.selectedObject = map.dataProvider;
        // toggle showAsSelected
        event.mapObject.showAsSelected = !event.mapObject.showAsSelected;
        // bring it to an appropriate color

function handleFormSubmit() {
   * Gather selected areas from all maps and populate
   * hidden fields with them
  for(var x in maps) {
    var map = maps[x];
    var states = [];
    for (var i in map.dataProvider.areas) {
      var area = map.dataProvider.areas[i];
      if (area.showAsSelected) {
    document.getElementById(x + '_field').value = states.join(',');
   * Add submited info debug information (optional step)
   * We're going to use jQuery to keep the code simple. However, jQuery
   * is not necessary to run the maps - we're just using it here to
   * print out debug info.
  var formData = [];
  jQuery('#user_form').find('input[type=hidden],input[type=text],input:checked').each(function () {
    formData.push( + ': <strong>' + this.value + '</strong>');
  document.getElementById('form-debug').innerHTML = formData.join('<br />');
   * Prevent form from actually submitting.
   * We probably don't want it in real life situations.
  return false;