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

Question

Question

Modern Form Designer (LF Form Essentials) - Javascript help for modifying dropdown value

asked on August 23, 2023

I'd like to use JavaScript in the Modern Form Designer to split a single line dropdown value from 1111|2222|3333 to multiple lines in the dropdown using the | as a pipe to separate the values. Since we are using LF Forms Essentials we are not able to use lookups to set dropdown values. I am using Workflow instead to set the value, but as far as I know Workflow can only set a single line in a dropdown.

I found the following code for the Classic Form Designer. Does anyone know how to apply this to the Modern Form Designer? Our LF Forms has been updated to include Inline/External JavaScript.

$(document).ready(function () { 
//Compile correct list of Owners in "Person Making Request Field"
//Loop through all options in the drop-down list.
  var options = $('.List_of_Owners option:first-child').text().split('|');
  var index;
  for (index=0; index<options.length; index++) {
    $('.List_of_Owners select.form-item-field').append("<option>"+options[index]+"</option>");
  }
  $('.List_of_Owners option:first-child').remove();
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Owners select.form-item-field");
//Prepend a blank option to the field
  $("<option>", { value: '', selected: true }).prependTo(".List_of_Owners select.form-item-field");
});

 

0 0

Replies

replied on August 23, 2023

I don't think this can be done with the modern designer. The code for modifying a dropdown in the classic designer relies on changing the actual HTML element on the page, but javascript runs in a sandbox in the modern designer so that's not an option. I don't think the LFForm object for the modern designer javascript has any methods that allow you to change dropdown options, but I think it would be a reasonable feature request.

0 0
replied on August 28, 2023

There was a feature request put in for this, over a year ago. Seems it may still only be in the consideration stage as a new feature... sadly.

https://answers.laserfiche.com/questions/196467/Dynamically-populate-dropdown-in-new-Forms-designer-using-the-LFForm-object#196513

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

Sign in to reply to this post.