Himanshu Kansal wrote:Hello,
According to what you are trying to do, things are happening correctly. You asked it to output the array object and that is what it gave u.
Concept of arrays for forms is that when you have a control like a series of checkboxes, you can use an array in your form to hold multiple selected values. The values in case of textboxes would normally be overwritten, instead of being mapped to arrays. I am not very sure but I think this is what happens to textboxes.
Still, if I assume that in case you have multiple textboxes, all with the same name attribute, and they do get mapped to the array in your form, then when you have a single textbox, you still would require to refer to its value through the array index, stockID[0] that is.
why cant a single text box map to an array of size 1?
If I refer to its value through the array index, when i add a new row of inputs (which clones the first row of inputs), we will have two input boxes which refer to the same array index.
For example:
Before adding a new row we will have:
"<input type="text" name="stockID[0]" maxlength="10" size="10" "
but after adding another row of inputs, we will get:
"<input type="text" name="stockID[0]" maxlength="10" size="10"
"<input type="text" name="stockID[0]" maxlength="10" size="10"
and when the form gets saved, only one of the inputs is stored and not both.