Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Adobe javascript AddInstance & checkbutton

Avatar

Former Community Member
Hi,



I have a question about adobe javascript in Livecycle Designer 7.1.

I created a form on it a button with javascriptcode addInstance (1).The button adds a new subform with a checkbutton in the it. At this

point, when i add more subforms, how do i "activate" all the checkbuttons

in the subforms?



I will give you an example to build up my question:



I have 2 subforms,

subformA with a buttonAdd (addInstance(1) )

subformB with 1 row and cellCB. In the cell there is 1 checkbutton, lets

name it CB1.

By pressing the buttonAdd, it will add a new subformB.



Now, I have 1 checkbutton (CBCheckAll), and when i press on this it will

"activate" all the checkbuttons (Cb1).

I am only able to check the first checkbutton, but when i add a new

cell, it doesnot check the 2st row or more.



I hope you can help me with this issue.



With kind regards,



Thaibinh Truong
3 Replies

Avatar

Former Community Member
Hello,



Lets see if I understood correctly. Try the following:



In FormCalc:



subformB[*].CB1.rawValue = 1



In JavaScript:



var oNodes = this.resolveNodes("subformB[*].CB1");

var nCount = oNodes.length;



for (var i =0; i < nCount; i++)

{

var oNode = oNodes.item(i);

oNode.rawValue = 1;

}



Hope this helps.



Cheers,



Hélène

Adobe Systems

Avatar

Former Community Member
Hi,



I have tried to integrate the script you adviced me, unfortunately it isnot performing the rquired result.



I pasted the part: subformB[*].CB1.rawValue = 1

in a event Calculate and language FormCalc.



This javascript part: var oNodes = this.resolveNodes("subformB[*].CB1");

var nCount = oNodes.length;



for (var i =0; i < nCount; i++) { var oNode = oNodes.item(i); oNode.rawValue = 1; }



was pasted in event Click and language Javascript for the CBCheckAll Button. Did I pasted it in the correct location?

Furthermore, i wonder why the javascript execEvent("click") isnt needed?



Below you can find my mailaddress. If not a problem you can mail me and I'll send you the PDF form.



With kind regards,



Thaibinh Truong

SAP PM/ECM consultant

t.truong@ideo-nl.com

Avatar

Former Community Member
From what I understand, you dont need the script on the calculate event. All you need is the script on the click event of the CBCheckAll button. Note both snippets provided earlier will achieve the same result. The only difference is the scripting language.



Lets take the JavaScript version. Youve already copied this script in the click event of the CBCheckAll button. This is just an example and may not be referencing the right objects in your form. You need to update the SOM expression passed to the resolveNodes() methode i.e. subformB[*].CB1.



Also, you may want to enable the JavaScript debugger. It will help you debug your scripts. When you are previewing the form, press CTRL+J. Then click on the CBCheckAll button. The warnings will show up in the JavaScript debugger.



Hope this helps,



Hélène

Adobe Systems