I'm trying to send onclick parameters with html onclick
for (var i = 0; i < 2; i++) {
    if (i == 1) {
        document.write(" <tr class='noBorder' onclick='foo(i)' >");
    }
    if (i == 0) {
        document.write(" <tr class='noBorder' onclick='foo(i)' >");
    }
}
However, whenever I click on a row, I get back onclick = foo(2)
I've been looking around and found the same question
Javascript - Dynamically assign onclick event in the loop
I was wondering if it is possible to do this with document.write?
 
     
     
    