$('#name[1]')
would look for an element with an id of name and an attribute [1]. You can try this instead:
$('[name="name\\[1\\]"]').val(myvariable);
This will search for an element with a name = name[1].
FYI, You have to escape the brackets with 2 backslashes like that because you're actually escaping two things. The double backslash "\" escapes to "\" in JavaScript. Then jQuery sees the "[" and escapes the bracket.