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

Question

Question

Selecting Custom HTML Elements with Javascript in New Form Designer

asked on January 18, 2022

Hello All, 

 

The past couple of days I have started using the Javascript function in the new Forms Designer. Full disclosure, I am by no means a developer or fluent in Javascript but have been able to put together some simple form enhancements in the classic Form Designer.

 

I'm finding the LFFORM much easier to use than Jquery for selecting fields, but cannot figure out how to select custom html elements. The documentation doesn't mention selecting other elements https://doc.laserfiche.com/laserfiche.documentation/en-us/Subsystems/ProcessAutomation/Content/Forms-Current/Javascript-and-CSS/TheLFFormObject.htm 

 

I have tried to simply copy over my Jquery code and tried html ids, css tags, and field ids and had no luck thus far. 

 

My current use cases are for a dynamic iframe, old code below and for some custom button functionality.

$( document ).ready(function() {
  
      changeIframe();

  
  $( "#q4" ).change(function() {
    changeIframe();
  });
     


  function changeIframe(){

    $("#myframe").attr("src","https://{laserficheURL}&docid="+ $( '#q4 input' ).val() +"#?openmode=OFFICE&mode=embed");

  }

});

 

If anyone knows a solution using the LFFORM Object or otherwise I would greatly appreciate it.

1 0

Replies

replied on March 1, 2022

I'd be interested to get an answer to this too. Based on the documentation, the LFForms object seems a bit limited so I'm wondering if there is functionality beyond what is spelled out in the doc.

0 0
replied on February 23, 2023

Information on this would be great for us as well.

0 0
replied on April 30

I'm not sure when it was added, but it's available to the LFForm object in at least v11.0.2311 and is in the Help documentation. Just in case others come upon this thread, here's what worked for me to dynamically modify a custom HTML field. The key is using changeFieldSettings and the property (key) "content". 

(This is the just basics. There was more to the script to trigger on change, etc. Also note that the content propery string is inclosed in backtics. This allows the variable to be inserted using ${variableName}.)

// field 4 contains an entry ID
let newValue = LFForm.getFieldValues({fieldId: 4});

// field 5 is the custom HTML field
LFForm.changeFieldSettings({fieldId: 5}, {content: `<iframe id="wc" src="https://laserficheURL/DocView.aspx?repo=RepositoryName&amp;id=${newValue}&amp;mode=embed" width="100%" height="700px"></iframe>`});

 

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

Sign in to reply to this post.