I am using a popup window
in this I may be having n number of input checkboxes(here I have taken 4)
like this <input type='checkbox' name='comments1' value='0' />
so I will be naming it comments1, comments2, and so on.....

and now to return it's values to parent window I am using this function

function Done() {

if (comments1.checked)
MyArgs[1][0] = 1;
else
MyArgs[1][0] = 0;

if (comments2.checked)
MyArgs[1][1] = 1;
else
MyArgs[1][1] = 0;

if (comments3.checked)
MyArgs[1][2] = 1;
else
MyArgs[1][2] = 0;

if (comments4.checked)
MyArgs[1][3] = 1;
else
MyArgs[1][3] = 0;

window.returnValue = MyArgs;
window.close();
}

now can do something like
if ( comments + i . checked) (not exactly like this )
I want to put it in a loop until the length of comments ( that is may be 1 .. 10, length I can determine) .