I am not sure why you would want to do that, but yes, it is possible.
Just make sure it is the right syntax. And you reference by "id", not by "name".
It makes a lot more sense to simply use document.getElementById() then continue from there.
For example, you have some elements called "element1", "element2", "element3".
You want to put different value for each of them.
for (i = 1; i < 4; i++)
var someelement = document.getElementById("element" + i);
Note the position of the <script> is after the <div>. Putting <script> at the top will not work, because the div cannot be identified.