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

Question

Question

Fill a collection with content from another collection

asked on April 3, 2018

Use case:  I have a form where submitter fills out what hardware is needed.  This is setup as a collection allowing the addition of multiple hardware items.

Page 2 is for IT to process the requested items as purchased items.  I want to copy the name of the requested item to the name of the purchased item in a second collection on page 2.

Using the =collection.fieldname syntax in the Advanced tab (collection from-to5) gets me all the hardware items requested in a single string in the first item of the collection on page 2 (collection from-to2).  What I want to accomplish is what you see in the collection from-to4 image.

 

How do I do this?

4-3-18 collection from-to.PNG
4-3-18 collection from-to2.PNG
4-3-18 collection from-to4.PNG
4-3-18 collection from-to5.PNG
0 0

Replies

replied on April 3, 2018

Hi Michelle,

I'll recommend JavaScript for mirroring values from one collection/table to another. See here.

The use case linked above maps values from a table to the corresponding fields in a collection. For Forms 10.3, the selector for the input of a field inside of a collection can be targeted with:

.myCollection > div.cf-collection.clearfix.kx-repeatable > div:nth-child(ROW) > ul.rpx > li.CLASS> div input

For example, the 2nd value of "Item Name-Purchase" (which I'll say has a class called 'itemNP'), can be read by:

var itemNP = $('.myCollection > div.cf-collection.clearfix.kx-repeatable > div:nth-child(2) > ul.rpx > li.itemNP> div input').val();

You can then set the 2nd value of "Item Name-Purchase" in the mirrored collection through:

$('.myCollection2 > div.cf-collection.clearfix.kx-repeatable > div:nth-child(2) > ul.rpx > li.itemNP> div input').val(itemNP);

The JS in the link above shows how to count the number of rows in the collection, set the number of rows in the second table, and mirror values for each row in the collection using a for loop.

Do let me know if you have any questions on that. 

0 0
replied on April 5, 2018

Tri, we are still using 10.2 yet you referenced the selector statement as working under 10.3.  Does that also apply to 10.2?

Please advise, thanks

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

Sign in to reply to this post.