123

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.

            
              <script src="//app-sj01.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_169"></form>

<a style="position:fixed;right:40px;bottom:40px;" href="">Reload this page</a>
            
          
!
            
              (function() {
  var ANCESTORS_STOR = '.mktoFormRow, .mktoFormCol',
    INPUTS_STOR = 'INPUT,SELECT,TEXTAREA,BUTTON',
    attrTag = 'data-wrapper-for',
    _forEach = Array.prototype.forEach;

  /* utility fn to tag wrapper containers with inner form inputs */
  function tagMktoWrappers(formEl) {
    _forEach.call(formEl.querySelectorAll(ANCESTORS_STOR), function(ancestor) {
      ancestor.setAttribute(attrTag, '');
      _forEach.call(ancestor.querySelectorAll(INPUTS_STOR), function(input) {
        var currentTag = ancestor.getAttribute(attrTag);
        ancestor.setAttribute(attrTag, [currentTag ? currentTag : '', input.id, input.name != input.id ? input.name : ''].join(' ').trim());
      });
    });
  }

  MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 169);
  MktoForms2.whenReady(
    function(form) {

      // config section: enter the field to unhide and the field it should appear like (and next to)
      var unhideField = {
        Name: 'LastName',
        Label: 'Last Name'
      };
      var displayLikeField = {
        Name: 'FirstName'
      };
      var insertBeforeField = {
        Name: 'Email'
      };

      var formEl = form.getFormElem()[0];

      tagMktoWrappers(formEl);

      // make a duplicate of the non-hidden field w/all its parent wrappers
      var displayLikeFieldEl = formEl.querySelector('.mktoFormRow[data-wrapper-for="' + displayLikeField.Name + '"]'),
        unhideFieldEl = formEl.querySelector('.mktoFormRow[data-wrapper-for="' + unhideField.Name + '"]'),
        insertBeforeFieldEl = formEl.querySelector('.mktoFormRow[data-wrapper-for="' + insertBeforeField.Name + '"]'),
        clonedWrapper = displayLikeFieldEl.cloneNode(true);

      // reset style and type of hidden field
      var unhideInputEl = formEl.querySelector('INPUT[name="' + unhideField.Name + '"]'),
        clonedInputEl = clonedWrapper.querySelector('INPUT');
      unhideInputEl.setAttribute('style', clonedInputEl.getAttribute('style'));
      unhideInputEl.setAttribute('type', 'text');

      // reset label stuff for formerly hidden field
      clonedWrapper.querySelector('LABEL[for="' + displayLikeField.Name + '"]').innerHTML = unhideField.Label;
      clonedWrapper.querySelector('LABEL[for="' + displayLikeField.Name + '"]').htmlFor = unhideField.Name;
      clonedWrapper.setAttribute('data-wrapper-for', unhideField.Name);

      // a little more housekeeping to not interfere with validation
      var innerDescriptor = clonedWrapper.querySelector('DIV.mktoFieldDescriptor');
      innerDescriptor.className = innerDescriptor.className.replace(/\s?mktoFieldDescriptor\s?/, '');

      // finally, put the formerly hidden field inside the wrapper and inject the whole thing into DOM
      clonedInputEl.parentNode.replaceChild(unhideInputEl, clonedInputEl);
      unhideFieldEl.parentNode.removeChild(unhideFieldEl);
      formEl.insertBefore(clonedWrapper, insertBeforeFieldEl);

    });
})();
            
          
!
999px
🕑 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.

Console