내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

addItems to Dropdown avoiding duplicates

Avatar

Level 3

Sir.

Link to the actual file  https://www.dropbox.com/s/0508by0lmlf77rc/repeatable%20Dropdown%20to%20another%20Dropdown%20which%20...

 

I have 2 dropdowns     

1st is in a repeating table  and 2nd one is in a repeatable subform

1st dropdown has options  say  Option1, Option2 ...... 

2nd Dropdown is empty when intialized

 

I want when user selects any option in dropdown 1  it should be populated in dropdown2  avoiding duplicates

so if user adds say 3 rows  and select in

1st Row : Option1

2nd Row : Option2

3rd row : Option3

 

then Dropdown2 should have the following options for the user to select from

Option1

Option2

Option3

if user goes back and deletes any row then that option should be removed from Dropdown2    and  duplicate items should be avoided. 

 

Thanks 

 

 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 10

This needs a combination of two loops. One to fetch the selected value and one to compare those already used.

 

 form1.MSF.SF_Notable.SF1.RB::enter - (JavaScript, client)

var oRows = Table1.resolveNodes('Row2.[Cell1 ne "  -Select-"]'),
	oNode, oItems, i, j, n, cValue;
this.clearItems();
for (i = 0; i < oRows.length; i += 1) {
	oNode = oRows.item(i);
	oItems = this.items.resolveNodes('#text[*]');
	n = 0;

	if (oNode.Cell1.rawValue === "  Example Other Member" ) {
		cValue = oNode.Cell2.rawValue;
	} else {
		cValue = oNode.Cell1.rawValue;
	}
		
	for (j = 0; j < oItems.length; j += 1) {
		if (cValue == oItems.item(j).value) {
			n += 1;
		}
	}

	if (n === 0) {
	    this.addItem(cValue);
	}
}

원본 게시물의 솔루션 보기

3 답변 개

Avatar

정확한 답변 작성자:
Level 10

This needs a combination of two loops. One to fetch the selected value and one to compare those already used.

 

 form1.MSF.SF_Notable.SF1.RB::enter - (JavaScript, client)

var oRows = Table1.resolveNodes('Row2.[Cell1 ne "  -Select-"]'),
	oNode, oItems, i, j, n, cValue;
this.clearItems();
for (i = 0; i < oRows.length; i += 1) {
	oNode = oRows.item(i);
	oItems = this.items.resolveNodes('#text[*]');
	n = 0;

	if (oNode.Cell1.rawValue === "  Example Other Member" ) {
		cValue = oNode.Cell2.rawValue;
	} else {
		cValue = oNode.Cell1.rawValue;
	}
		
	for (j = 0; j < oItems.length; j += 1) {
		if (cValue == oItems.item(j).value) {
			n += 1;
		}
	}

	if (n === 0) {
	    this.addItem(cValue);
	}
}

Avatar

Level 3

@radzmar Thanks again

This works perfect.

Avatar

Administrator

Good to see you in AEM community. Nice you have great SME like you.  



Kautuk Sahni