Is there a way to know the dimensions of a form?

Robb_Barrett
Marketo Employee

Is there a way to know the dimensions of a form?

I'd like to have a page that adjusts its height according to the size of the form, including adjustments when fields become visible.  Is there a way to get this information and put it into a page size token?

Robb Barrett
2 REPLIES 2
Grégoire_Miche2
Level 10

Re: Is there a way to know the dimensions of a form?

Hi Robb,

Unfortunately, this is not possible. But from your question, I gather you are using a free-form template, isn't it ? If this is the case, event though, I am not sure that your could use this token to reformat the page anyway, at least not without some scripting.

If so, you may want to consider moving to Guided Landing Page Templates (i.e. Responsive design) that would be able to support this "naturally".

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Is there a way to know the dimensions of a form?

+1 to everything Greg said. 

The maximum possible height of the form including visibility rules is not computed.  It would be impossible for Marketo to do this on the server, in any case, since they have no idea of what other CSS you're applying to the form.  (Not sure why you'd want to fit to the maximum height, anyway, as your page might like mighty strange with whitespace allocated for fields that aren't rendered.)

It is possible to read the (probable) width of the form via JavaScript (which could potentially be done before the form is made visible): forms.js makes this easily accessible by applying an element style to the <FORM>. However, the width might also have to be overridden using local styles if it upsets your layout, so you'd actually have to interrogate the current dimensions at runtime.

If you want complete control over form layout, start with something like my destyled form and then build from there.