我想用havascript在html中的文本框中总结循环名称

I guys I am New to php and javascript and I have a problem I want to loop the name inside the textbox

< form name ="rec" action="this.php" method="post" >
<  ?php 
   x=0; 
   while(x <=5){
     x++;
     echo" < input type='text' name='n".$x."'>";
?> 
< /form>
< script > 
  x=0; 
  while(x <=5){
   x++;
   a = Number(document.rec.n"+x+".value)
   document.rec.n"+x+".value = a;
  } 
< /script>

I hope you understand the php is working but I dunno how to loop inside the name of the javascript. need help

instead of this:

document.rec.n"+x+".value

try this:

document.rec["n"+x].value