Form on known lead HTML

Nicholas_Manojl
Level 9

Form on known lead HTML

I have an embedded form.

I would like to use both the known lead custom HTML ("Welcome back {{lead.FirstName}}").

I would also like to include an additional enquiry form..

Can I somehow include an HTML form element that writes to {{lead.enquiry message}}?

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Form on known lead HTML

Sure, you can trigger the embedding of an alternate form using JS in the KL HTML.  Just do it the usual way with MktoForms2.loadForm(). This uses more resources than would be ideal (downloading two form descriptors and rendering two forms in total) but it'll work.

Alternately, you could add a new <textarea> within the KL HTML (I'm assuming enquiry message is a textarea) and append its value to the form in an onSubmit listener. (Remember, the form is still submitted when the lead clicks the {{form.Button}}, and you can still listen to form events as usual.)  But this is a bit far afield and I don't like adding form elements unless there's truly no backing field (in this case, you have the corresponding field in your Marketo database.)

Nicholas_Manojl
Level 9

Re: Form on known lead HTML

I seem to be having trouble getting JS into the KL custom HTML.

pastedImage_0.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Form on known lead HTML

You can't put the 2nd <form> inside the 1st one!  You can trigger the embedding of the other form, but one can't literally nest inside the other. You can have the forms as DOM siblings.

Nicholas_Manojl
Level 9

Re: Form on known lead HTML

No, that was a bit of a long shot. But I figured the method would be putting some sort of script inside the Known Lead custom html section.

SanfordWhiteman
Level 10 - Community Moderator

Re: Form on known lead HTML

You can put JS right in the KL HTML.

Or you can put an identifying tag (like <div data-replace-with="mktoForm_1235">) in the KL HTML and look for it in the MktoForms2.whenReady JS event.

What you can't do is put a <form> inside a <form>. This is an HTML rule, not a Marketo quirk.

Nicholas_Manojl
Level 9

Re: Form on known lead HTML

Weird.. yesterday my HTML editor was basic with no rich formatting capability.

Nicholas_Manojl
Level 9

Re: Form on known lead HTML

However.. I found that pasting the embed code did indeed work...

pastedImage_0.png