I only manage to access non array named form fields.

Code:
<form method="post">
<input type=checkbox name=check[]>
<input type=text name=justinput value=testing>
<hr>
<input type=checkbox name=check[]>
<input type=text name=input[] value=foo>
<hr>
<input type=checkbox name=check[] onclick="getthis(form, this)">
<input type=text name=input[] value=bar>
</form>

<script>
function getthis(form, test) {
form.justinput.value="foobar" // works
document.getElementById('justinput').value="foobar" // works
//form.input[0].value="foobar" // fails
//document.getElementById('input[0]').value="foobar" // fails
}
</script>
Is there a way to at least get the index out of the clicked checkbox, and thus being able to access its matching input[]?