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

Question

Question

Can a Forms table be automatically populated with rows for every look up choice?

asked on November 17, 2015

I am working in Forms and would like to know if anyone can tell me how to use a table to show all the choices from a lookup?

For example, I have a drop down box above the table with Shirts or Pants as choices.  If the user selects Shirts, I want a table below the drop down box to show a row for all the choices (currently it will only have one row and a drop down box of choices with the ability for the user to add more rows).

In the screenshot below, what I want to be the result is when they choose Shirt, the table will automatically have 11 rows and each of the choices will be in a row.

 

Current:

 

Result I want (without the user having to add the rows manually):

 

Thanks.

0 0

Replies

replied on November 17, 2015 Show version history

Here's a proof of concept that may help you get started. Give your initial drop down field a CSS class name like clothes. Then have a second drop down field be used for the returned values from the lookup. In my example, this second drop down field will actually be Field3/q3 and I'll have it hidden by default. The JavaScript below will loop through each value returned from the lookup, insert it into a field in a table row, and then click the "Add" button. Note that the field in the table is a single line field (Field7) in my example.

$(document).ready(function () {
  
  $('#q3').addClass('hidden');
  
  $('.clothes select').blur(function() {    
    
    var x = document.getElementById("Field3");
    var i;
    for (i = 1; i < x.length; i++) {
      $('[name="Field7(' + i + ')"]').val(x.options[i].text);
      if (i < (x.length - 1)) {
        $('.cf-table-add-row').trigger('click');
      }
    }
  });

});
0 0
replied on January 15, 2016

Hi there,

Populate Table field with multiple return results from DB lookup is supported in Laserfiche Forms 10.

0 0
replied on March 15, 2016

That's great that it is in Forms 10, but we are not at a place where we can go up to Forms 10 right now.  We are still months away from going to 10.

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

Sign in to reply to this post.