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

Question

Question

Forms Designer Javascript to pre-fill table rows

asked 8 hours ago

I have a form that will have tables with a field pre-populated for the user. So in the example below, when the user opens the form the Equipment column would be prefilled with these 8 options, and then they can add the hours, and add additional rows with their own value if needed.

I'm wondering if something like this is doable with Javascript in the Forms Designer? If not I can probably throw it into a database table and do a lookup, but JS would be great if possible. 

0 0

Replies

replied 2 hours ago • Show version history

Here's some JavaScript that should do the job for you (tested on Forms Version 12.0.2509.20409).

//This ID needs to be updated for your specific field.
const equipmentFieldId = 6;
const equipment = [
  "FTL-11",
  "TFL-18",
  "TFL-35",
  "TDS-03",
  "Skidsteer Trailer",
  "Skidsteer",
  "Cutter Trailer",
  "Cutter"
];
//We could insert the whole array, but that
//could cause problems for the "fillable text"
//rows at the bottom, so we'll use a loop
//to update the values one row at a time.
equipment.forEach((e, i) => {
  LFForm.setFieldValues({fieldId: equipmentFieldId, index: i}, e);
  LFForm.disableFields({fieldId: equipmentFieldId, index: i});
});

 

That script assumes the table has at least 8 rows on it at all times.

 

Setting your table up with 8 as the minimum looks something like this.

Note that does give you the ability to delete the fixed value rows.  If that's a problem, it'll need to be addressed separately, perhaps with CSS to hide the delete buttons.

 

If you are making the table with a fixed number of rows, it'll look something like this.

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

Sign in to reply to this post.