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.