Q:

Assigning Text Box Values to a String Array in Javascript?

Is there a way to assign each of the values I enter into multiple text boxes into a string array in JavaScript?  
javascript
<script type="text/javascript">
  var ch[];

  function getAllValues() {
   alert('Entered');

   for(var i=0;i<5;i++) {
      ch.push(document.getElementsByName("src")[i]);
    };

 alert(ch);
}
</script>

home.jsp
<form method="post" name="myform" onsubmit="getAllValues();">//
    <%
        for (int i = 0; i < 5; i++) {
    %>
    <input type="text" name="src"/ >
    <%
        }
    %>
    <input type="submit" value="submit">
</form>

var ch[];

Here there are 5 text boxes. I want to assign the values entered here into an array using JavaScript.
Does anybody have any idea how to do this? I was stuck on this for 2 days.

A:

for(i=0;i<5;i++) {
  ch.push(document.getElementsByName("src")[i]);
}

Edit
<% for(int i=0;i<5;i++) { %>      
  <input type="text" name="src" onBlur="srcBlur()" />
<% } %>

...
var src = new Array();

function srcBlur(this) {
  if(this == document.getElementsByName("src")[0]) src[0] = this.value;
  else if(this == document.getElementsByName("src")[1]) src[1] = this.value;
  else if(this == document.getElementsByName("src")[2]) src[2] = this.value;
  else if(this == document.getElementsByName("src")[3]) src[3] = this.value;

  if(src[0] && src[1] && src[2] && src[3] && src[4]) {
    for(i=0;i<5;i++) {
      ch.push(src[i]);
    }
  }
}

