Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to get the handle of all text fields in the subforms, using script

Avatar

Level 2
Hi Friends,

I have around 20 fields in a subform, how can i get the names of all the fields using script.



I wish to enhance the following script where the field names are hard coded

thereby the script itself will get the names of the field names.



var f1 = this.parent.somExpression + ".TextField2" + ",";

var f2 = f1 + this.parent.somExpression + ".DropDownList1" + ",";

var f3 = f2 + this.parent.somExpression + ".NumericField1";

xfa.host.resetData(f3);



Any help will be greatly appreciated..



Thanks

JJ
2 Replies

Avatar

Former Community Member
Instead of using this.parent.somExpression (this gives you the somExpression for the container object) just use this.somExpression and that will give you the somExpression for the object.



If you want to keep your code the way it is you can also use this.name to just get the object name.

Avatar

Level 2
Hi Paul,

Thanks for your comments.

I achieved the clear contents by resetting, by taking input from your thoughts..



form1.sub1.sub2.sub3.table_1.addDelete_Top.addDelete.deleteRow::click - (JavaScript, client)

----------------------------------------------------------------------

//Here is my code finally look like..

//row 1, table_1 are also subforms

for (var i=1;i<10;i++){

var myRow = this.resolveNode("table_1.row1[" + i + "]");

if(myRow.presence == "hidden"){

i = i-1;

var myRowDelete = this.resolveNode("table_1.row1[" + i + "]");

if(i!=0){

xfa.host.resetData(myRowDelete.somExpression);

myRowDelete.presence = "hidden";

}

break;

}

if(i==9){

xfa.host.resetData(myRow.somExpression);

myRow.presence = "hidden";

break;

}

}

//----------------------------------------------------------------



Thanks

JJ