Server operations like Sawtooth Script are performed before any client operations like JavaScript, so you cannot pass JavaScript variables into Sawtooth Script like you have done with "i."
Your code snippet does not show how "i" is set. Depending on that, the best solution to your problem may be to replace your loop in JavaScript with a loop in unverified Perl. Something akin to this:
var MainList = [% Begin Unverified Perl
my $str = '[';
my $sep = '';
for (my $i = 1; $i <= 10; $i++) {
$str .= $sep . LISTVALUE('brandlist', $i);
$sep = ',';
}
$str .= ']';
return $str;
End Unverified %];