Skip to main content
Mar 1, 2017 9:06 PM UTC
Solved

Prevent hidden fields from taking up space on form

Hello Community,

Does anyone have any experience with creating hidden fields on a Marketo form that do not take up any space on the form HTML? Right now, when I create a hidden field, it is hidden, but is still producing a  div.mktoFormRow which is pushing the div.mktoButtonRow down 10px per field. Is there someway to prevent this default wrapping? Or to just insert the hidden field before the end of the form? 

Thank you in advance!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Mar 2, 2017 12:56 AM UTC

Changing the widths of the parents of input:hidden elements from 100% to 0px.


MktoForms2.whenReady(function(form){

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

            hiddenEls = formEl.querySelectorAll('.mktoFormRow INPUT[type="hidden"]');

  

    [].forEach.call(hiddenEls,function(el){

        el.parentNode.style.width = '0';

    });

});

14 replies

SanfordWhiteman
User Group Leader
User Group Leader
Mar 1, 2017 9:16 PM UTC

INPUT[type="hidden"] {

  margin-bottom: 0 !important;

}

Translate
Mar 1, 2017 9:35 PM UTC

Thank you for your reply, Sanford. This does remove the 10px margin-bottom, but the div is still taking up space and pushing the button down. Any other thoughts?

Translate