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

Question

Question

Populate Fixed table with lookup values

asked on September 22, 2015

Hello Team,

I've been searching all over this sit with no luck on how to populate my table with values from a database lookup.

The table is of a fixed number of rows. I have created hidden text fields that will populate with the values, each one corresponding to a row int he table. What i'm stuck on is how to get the info from the text field to the corresponding table row.  I don't believe the code is very long, But attached is a screenshot of my table and my hidden fields. 

 

 

My table is CSS class table, the table column is CSS class filledField, and the hidden text fields are HCity1 and HCity2.

Thanks for assistance!

0 0

Replies

replied on September 22, 2015

Claude,

You'll want to do this on the Lookup Rules Tab.  Follow the steps below to accomplish this.  

1  Make sure Forms has access to the Database by going to the Administration Menu  in the top right-hand corner, once you're logged in as an administrator.  

2.  Navigate to Data Sources and New Data Sources .  Enter the requested information and test the connection.  

3.  Once that is done, you'll want to make sure the specific Form has access to see this data source.  Do this by accessing the Processes section of the page and Add/Remove the selected Forms that should have access.  

4.  Open the selected form and navigate to the Lookup Rules tab to configure the lookup rule

5.  Delete the conditional and Select the Laserfiche Field you want to fill, and with what DB Field (see below).  I have found that this works best if the field is already a drop-down type field, otherwise users may not know values can be selected...  

Hope that helps!

Cheers

0 0
replied on September 22, 2015

Hi Nate, Thanks for the reply, but that method won't work, it will populate the table with all the same value.

0 0
replied on September 22, 2015

Got it - Didn't read into it enough...  It will take some Javascript to assign a hidden field a value based on the row...  I was able to get the following script to work for me.  You will need to setup a conditional fill in the lookup rules tab.  

$(document).ready(function () {

    $(document).on('click', '.form-del-field', function () {
        rowNumbering();
    });

    rowNumbering();
    $('#q2').click(rowNumbering);

    function rowNumbering() {
        currentRow = 1;
        $('.cf-table-block tbody tr').each(function () {
            $(this).find('.rowNum input').val(currentRow);
            currentRow++;
        });
    }
});

A couple things you'll need to change = #q2 should be the add button in your table and then assign that field the rowNum class.  I've tested this and it did the trick for me.  

Nate

0 0
replied on September 22, 2015

Thanks again Nate!, really appreciate your assistance. However, i'm not trying to fill the hidden fields with values from the table. It is the opposite. Also, there is no add button as the table is of fixed rows.

So just image a table with 2 rows, and 2 hidden text fields. I populate the hidden text fields with a lookup rule. They trigger an event with the .change() method. Im trying to write the javascript code to populate when HCity1 populates, it triggers a .change() event, an the table row City1 populates with the same value. When HCity2 populates, tow City2 fills.

I don't necessary need to loop either, since it is a fixed number of rows, I can just hard code each instance. 

I want to believe it is just a few lines of code repereted over and over for each set.

0 0
replied on September 30, 2015

Since you need a fixed number of rows, I would create multiple tables with different class names so you can reference them in code. To make them look like rows, add one more class name called "tablerow", then put this in your css file:

li.tablerow div.cf-section-header {display: none;}

You should be left with something that looks like:

At this point, it is a matter of some javascript to reference the "tablerow" tables and put your values in on the .change() events. When it comes to tables in Forms, I have had better luck using classnames to reference specific fields.

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

Sign in to reply to this post.