Hi again,
here may be a small explanation.
With the first "for" statement you can create new repeating sections.
Put a repeating section (name Result for top node and Results for repeating node) to your form and add one textbox control to it.
Put a button to your form and copy the code (after conversion though) into your onClick event of the Button.
Then change yourUserName-ApprovalCount to the number 4 within your the for statement.
Preview your form and click the button, then it should actually generate 3 additional section including a textbox control. Each of this repeating section has an index or lets call it position starting from 1 i think.
The second "for" statment now is used to fill data into the textbox control within your repeating section.
So this means nothing more then iterating through your sections.
thisXDocument.DOM.selectSingleNode("my:myFields/my:Result/my:Results[" + j + "]/my:nameOfTextBoxControlWithinYourSection")The "j" is actually the position or index of your repeating section so if this value is 3 for example you will wirte a value into the textbox control of your third section.
Does this help you understanding it a bit better ?