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

Question

Question

Prefill data in collection based off what was entered on prior line?

asked on April 1, 2019 Show version history

We are working on setting up our Expense Reports in Laserfiche Forms. We have a collection where an employee would enter job# and fill out details on the expense. For ease of data entry on our employees, is it possible for the collection to copy the job# they enter on line 1 so it displays as the job# on line 2 when they click add?

If so, how would I go about this? I am assuming this would take some JavaScript, that I don't have much knowledge of, but am willing to learn. I attempted to use this code from https://answers.laserfiche.com/questions/114512/Copy-data-within-a-collection#114714, but I couldn't seem to get that one to work despite changing the id and Field numbers to 29 so I'm not sure what I'm missing. Any help is greatly appreciated! Thank you!

$(document).ready(function() {
  $('a[ref-id="q1"]').click(function() {
    var elementCount = document.getElementsByName("q3").length;
    document.getElementById("Field3(" + elementCount + ")").value=document.getElementById("Field3(1)").value;
  });
});

 

0 0

Replies

replied on April 1, 2019

Make sure you use the right question numbers in the java script or it will not work. It looks like you should use q10 for the add link and q29 for the job number instead of q1 and q3.

$(document).ready(function() {
  $('a[ref-id="q10"]').click(function() {
    var elementCount = document.getElementsByName("q29").length;
    document.getElementById("Field29(" + elementCount + ")").value=document.getElementById("Field29(1)").value;
  });
});

 

0 0
replied on April 2, 2019

Thanks for the help! I've copy & pasted this exactly into the Javascript portion of my form, but it still doesn't seem to copy the job# entered. Am I missing something?

java.PNG
java.PNG (29.97 KB)
0 0
replied on April 2, 2019

Please disregard. Just realized my form had tables, not collections, so that was why this wasn't working. Whoops!

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

Sign in to reply to this post.