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

              
                <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>
              
            
!

CSS

              
                
              
            
!

JS

              
                (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

Console