Expand my Community achievements bar.

SOLVED

Help with this code please...

Avatar

Former Community Member

Hi All

I have a repeating row in a table (+\- button on each row to add / delete). On each row the user selects a value from a drop down (the dropdown list is populated from a JavaScript object literal if that makes any odds)

What I need to do is to check for duplicate drop down selections on different rows and warn the user they have selected a value twice.

I currently have this code in the change event of the dropdown which works great but for the first row only - how do I tweak it to work for every instance of the repeatable row 'FullRowSubForm'??

if (xfa.event.newText == form1.WorkforceDepSubForm.WorkforceLineSubform.FullRowSubForm.RepeatableRow.WorkforceRow1.WorkforceNameTextField.rawValue)

{

    xfa.host.messageBox("WARNING you have already selected " + xfa.event.newText + "\n" + "\n" + "Only one instance of dependencies should be selected - please pick another dependency or delete.");

}


Thanks in advance

Ellis

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Your repeating element is FullRowSubForm, not sure if that is correct ... there maybe too many .parent's in the add code

Anyway, this should work.

if (form1.WorkforceDepSubForm.WorkforceLineSubform.resolveNodes("FullRowSubForm.[RepeatableRow.WorkforceRow1.WorkforceNameTextField == \"" + xfa.event.newText + "\"]").length > 0) {

Regards

Bruce

View solution in original post

4 Replies

Avatar

Level 10

Hi Ellis,

You'll have to change the XFA object names to match your form but this in the change event of the DropDownList (DropDownList1 in this case) should do it;

if (form1.Main.Table1.resolveNodes("Row1.[DropDownList1 == \"" + xfa.event.newText + "\"]").length > 0) {

  xfa.host.messageBox("WARNING ... ");

}

So if there is already a row with a DropDownList1 with the same value as the one just selected then display the message.

Regards

Bruce

Avatar

Former Community Member

Hi Bruce

Many thanks for the code - it's almost there. The only issue is that it seems to check for duplicates of the first row's value only. So it works great looking for duplicates of the first row however allows duplicated rows of any other value - as per the image here where 'Workforce B' is repeated:

duplicate.JPG

I have uploaded the section of the form below as I imagine solving referencing issues is tricky without seeing the form layout - any further help much appreciated.

Thanks again mate

E

Dropbox - PRELOADED v1.5 BIA v5 For forum.pdf

Avatar

Correct answer by
Level 10

Hi,

Your repeating element is FullRowSubForm, not sure if that is correct ... there maybe too many .parent's in the add code

Anyway, this should work.

if (form1.WorkforceDepSubForm.WorkforceLineSubform.resolveNodes("FullRowSubForm.[RepeatableRow.WorkforceRow1.WorkforceNameTextField == \"" + xfa.event.newText + "\"]").length > 0) {

Regards

Bruce