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

Question

Question

Auto Fill Button?

asked on January 22, 2014

I have been putting together a form that does a data source lookup to populate some of the fields. I currently have it so someone chooses a School ID and if the Teacher Status = 1 in the table it shows teachers with that status. Next to my status field there is an Auto Fill button that has to be clicked before the teacher information is populated. Is there a way to make the Auto Fill button go away? Why is it there? I plan on hiding the Status field, so I don't want anyone to have to click a button before getting the list of teachers.

Capture.JPG
Capture.JPG (61.16 KB)
0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied on January 22, 2014

The button appears because you have multiple conditions that must be met before the lookup will happen. There should be a pretty straightforward way around this. Here's an example. The fields that are used in the conditions for the lookup rule are given the lookupCondition class.

 

$(document).ready(function () {
  
   function autofill() {
    $('.autofill').trigger('click');
  } 
  
  $('.lookupCondition').change(autofill);
  
});

Then you can hide the button using this CSS rule:

 

.autofill {display: none;}

 

10 0
replied on March 19, 2014

How would this be used in a table? I have a table where each row requires two drop-down field values to be selected and then calculates a distance. The example above works for the first row, but not additional rows.

0 0
replied on March 19, 2014 Show version history

I added some handling for tables, let me know if that resolves the issue for you.

 

 

function tableAutofill() {
  $('.cf-table-block tbody tr').each(function () {
  $(this).find('button.autofill').trigger('click');
});
}

function autofill() {
$('.autofill').trigger('click');  
}

$(document).ready(function () {
 
  $('.lookupCondition input').blur(autofill);
  $('.cf-table-block').change(tableAutofill);

});


 

0 0
replied on March 19, 2014

I replaced the code I had with the code you supplied, but it still only fills in the first row, and not the others.

0 0
replied on March 19, 2014

I updated the code example above, let me know if that solves the issue.

0 0
replied on March 19, 2014

That did it! Thank you!

0 0
replied on March 19, 2014

You're welcome!

0 0
replied on January 9, 2015

Eric,

 

I have a form that has multiple (about 100) complex lookups.  This only works on one field when I try it.  Any modification to this that you could offer to get it to select all the auto fills?

 

Thank you,

 

Jennifer

replied on July 6, 2015

Eric,

I have this same scenario as Blake except my field in not in a table. I applied your suggested code:

 
   function autofill() {
    $('.autofill').trigger('click');
  } 
  
  $('.lookupCondition').change(autofill);
  

and then proceeded to hide to button but for some reason the function is not being fired off when the form starts. I added a windows.alert to verify this.

Any suggestions why this may not be working?

 

Thanks

 

Any suggestions?

0 0
replied on July 6, 2015

This is not supposed to work on page load, it is supposed to work when the field given the CSS Class 'lookupCondition' is changed.

0 0
replied on July 7, 2015 Show version history

Thanks Kenneth, you are right it only fires off when the field is changed.

With that, I used the change to a normal input field to fire off this function.

Thanks for your help.

1 0

Replies

replied on August 5, 2014

Hi Eric,

 

I am unable to get this to work, I first have JavaScript populate the row number, which you helped me with.  I now need it to wait until a position is selected in a drop down and then the auto fill button "pushed".  Here is what I have.

 

$(document).ready(function () {
    rowNumbering();
    $('#q2').click(rowNumbering);
 
    function rowNumbering() {
        currentRow = 1;
        $('.cf-table-block tbody tr').each(function () {
            $(this).find('.rowNum input').val(currentRow);
            currentRow++;
        });
    }
});
    function tableAutofill() {
          $('.cf-table-block tbody tr').each(function () {
          $(this).find('button.autofill').trigger('click');
        });
    }
 
    function autofill() {
        $('.autofill').trigger('click');  
        }
 
$(document).ready(function () {
  
  $('.lookupCondition input').blur(autofill);
  $('.cf-table-block').change(tableAutofill);
 
    }); 

 

 

2014-08-05_1955.png
0 0
replied on August 6, 2014

Hi Jessica,

 

Try this:

 

$(document).ready(function () {

    $('#q1 select').change(tableAutofill);
    rowNumbering();
    $('#q2').click(rowNumbering);

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

 

1 0
replied on August 6, 2014

It worked!

 

Thanks!

0 0
replied on August 6, 2014

You're welcome!

0 0
replied on November 20, 2015

Hi Eric,

 

I have a drop-down for selecting Organization and a lookup rule to populate 'amount per user' in 6 different tables. I would like to look for an alternative to auto fill button as sometimes the user might not click it.

I've tried making the 'amount per user' fields required, both via Forms as well as javascript, but the form can submitted with no input in them.

Thanks

Capture_autofill.PNG
0 0
replied on August 10, 2017

Hi All,

 

So I got this solution to work - but my multiple criteria are within a collection. So for the first collection, it works beautifully. However, when another collection is added, the functionality disappears. Does anybody know how to apply this to all collections a user might want to add? Thanks!

You are not allowed to follow up in this post.

Sign in to reply to this post.