Hello friends,
I need help with a simple program written in HTML using JS.
I have a form which contains a table(using table tags) which has 4 rows and the last column has text boxes. ie. 4*4
What I want to do is take the values from the text boxes and store it in an array in a loop.
here are my 4 text boxes:
<form>
.
.
<table>
.
.
<input type = text name = item1 value = "">
<input type = text name = item2 value = "">
<input type = text name = item3 value = "">
<input type = text name = item4 value = "">
.
.
<table>
</form>
I have a button, say OK, in the form
<input type = button name = "OK button" value = OK onclick = process(this.form)>
Here is my script
<SCRIPT language = javascript>
var myArray = new Array()
function process(f){
for(var i = 0; i < 3; i++){
myArray[i] = f.item.value //this is not correct; indexing needed to f.item.value
}
for(var i = 0; i < 3; i++){
document.writeln(myArray[i])
}
}
</SCRIPT>
how can I use indexing to the text field names and store them in myArray?