You are viewing limited content. For full access, please sign in.

Question

Question

How to trigger on change event using LFForm object in modern forms

asked on May 15

how to trigger on change event using LFForm object in modern forms

0 0

Replies

replied on May 15 Show version history

Any change to the field value, including changes via Javascript, should trigger the event.

But it sounds like you are asking about triggering the event without actually changing the value - which unfortunately, I don't think is possible.

I have one form where I getthe field value and store it in a variable, clear it from the field (which triggers the change event), and then put the value back into the field (which triggers the change event again).

3 0
replied on May 15

Depending on what you're trying to do, something like this should work:

LFForm.onFieldChange(function() {
  if (LFForm.getFieldValues({fieldId: 33}) === "Option 1") {
    LFForm.changeFormSettings({title: "Title 1"});
    LFForm.changeFormSettings({description: "Form Description 1"});
    LFForm.changeFieldSettings({fieldId: 30}, {label: "Field Label 1"});
    LFForm.changeFieldSettings({fieldId: 8}, {placeholder: "Placeholder 1"}); 
 } else { 
    LFForm.changeFormSettings({title: "Title 2"});
    LFForm.changeFormSettings({description: "Form Description 2"});
    LFForm.changeFieldSettings({fieldId: 30}, {label: "Field Label 2"});
    LFForm.changeFieldSettings({fieldId: 8}, {placeholder: "Placeholder 2"});
    }
}
, {fieldId: 33})

Just change the field ID's to the field you're wanting to watch (33, x2), and the fields you're wanting to update (30 & 8). Then repeat the lines as necessary to account for any additional fields.

1 0
replied on May 15

Can I do alert() with LFForm for troubleshooting?

0 0
replied on May 15

I am trying to set a custom HTML field via LFForm, how do I do that?

0 0
replied on May 15

You can't use alert() in the Layout Designer like you can in the Classic Designer - but you can still use console.log().

0 0
replied on May 15

Changing a Custom HTML field is done via the LFForm.changeFieldSettings function and editing the "content" of the field.  This is the example from the LF11 Help Documentation: 

LFForm.changeFieldSettings( {fieldId: 12}, {content: "<a src='https://www.laserfiche.com'>Laserfiche</a>"} );

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.