SOLVED

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Go to solution
DhananjayaW
Level 2

Can you update the label of a field in a Marketo form via the script at the page load?

Hi all,

I have created two custom fields named,

  • Custom Info Field_Str 
  • Custom Info Field_Text

The idea is to add these two fields into a Marketo form for specific events where we need to ask a specific question i.e. Dietary Requirement, Additional Comments, Travel Arrangements etc. Rather than creating a new field everytime or a new form everytime, I want to use these two fields in a form.

But is there a way I can modify the field label at the form load, so that the using the same form and same fields, I can ask different questions at different event pages?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Use the JS here:

MktoForms :: Dynamic Labels

 


Also on a different question, does PMCF appear when building forms as a field?

Yes, it should appear in Form Editor. Note the form must be in a Program to know which Program to update.

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Can you update the label of a field in a Marketo form via the script at the page load?

On form load, yes (not on page load).

 

But before I tell you how to do this, I wonder why, specifically, you’re not using Program Member Custom Fields (PMCFs) for this purpose. PMCFs are purpose-built to hold program-specific (and thus event-specific) data.  Even a multipurpose PMCF is better than a multipurpose Lead field, since its data is not overwritten by subsequent events.

DhananjayaW
Level 2

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Hi @SanfordWhiteman ,

The custom questions aren't always the same and can be different on each event. For example at one event we might ask for Dietary Requirements where as for a corporate golf event we might ask for the Tee Score. To avoid creating multiple fields, I want to create one (or two) field(s) that we can use and burn soon after it's used. 

Does that make sense? 

Can the label be updated at the form load with a code snippet on the hosting site? (we embed the marketo form in a wordpress site using the script).

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you update the label of a field in a Marketo form via the script at the page load?

OK, but that’s still not an explanation for why you wouldn’t use PMCFs.

 

You can have a PMCF called “Event-Specific Question 1” which can be used in one Program as as Dietary Requirements while in another Program it’s labeled as Tee Score. However — and this is the power I think you’re not getting — the values will not be overwritten. And there’s no reason to overwrite such data, if anything the dietary requirements are important metrics as you plan future events.

DhananjayaW
Level 2

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Hi @SanfordWhiteman ,

If I go with the campaign member fields, still how to I change the label of that "Event-Specific Question 1" dynamically at the form load, rather than creating a new form everytime? This is the main part of my question. 

Also on a different question, does PMCF appear when building forms as a field? 

DhananjayaW_0-1629885269664.png

DhananjayaW_1-1629885380197.png

I tried to create a "Campaign Member Field"called "Dietary Requirements" but it doesn't appear (not available in the field dropdown) when building the form. 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Use the JS here:

MktoForms :: Dynamic Labels

 


Also on a different question, does PMCF appear when building forms as a field?

Yes, it should appear in Form Editor. Note the form must be in a Program to know which Program to update.

Yan_Mak
Level 2

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Hi, 

 

I know this is a old post. But I want to make it work for "Drop down field" and "validation message" too, for some reason is not working when I have a "Drop down field".

 
Thanks,
Yan
SanfordWhiteman
Level 10 - Community Moderator

Re: Can you update the label of a field in a Marketo form via the script at the page load?

Should work fine for the <label> of a Select field. If it’s not, please link to your page.

 

Validation message is an entirely other area requiring different code.