It would probably be easier to name them
<input type="text" name="txtfield-1-2" />
Then, in PHP, you access them with
for (i = 1; i <= m; i++)
for (j = 1; j <= n; j++)
whatever($_POST["txtfield-$i-$j"]); /* or $_GET[...] */
In JavaScript, you do something like
for (i = 1; i <= m; i++)
for (j = 1; j <= n; j++)
whatever(document.getElementById("txtfield-" + i + "-" + $j).value);
I am assuming that these are in some kind of grid, so m
and n
are known. If not, Ek0nomik's solution would suit you better, although the regex should be \.*\[([0-9]+)\]\[([0-9]+)\]
(\[
and \]
should go outside of (...)
and quantifier +
should be added to allow indexes larger than 9) or, a bit more precise, ^txtfield\[([0-9]+)\]\[([0-9]+)\]$
.