470,841 Members | 905 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

multidimensional name-attribute and javascript

In my HTML forms (created by PHP) for attribute
names I have been using multidimensional arrays as illustrated
in the following:

<table>
<tr>
<td> ID </td>
<td> [1661] <input TYPE=hidden Name=frm_s[0][0] Value=1661></td>
<td> [1662] <input TYPE=hidden Name=frm_s[1][0] Value=1662></td>
<td> [1663] <input TYPE=hidden Name=frm_s[2][0] Value=1663></td>
</tr>
<tr>
<td> Name </td>
<td><input TYPE=text NAME=frm_s[0][1] ></td>
<td><input TYPE=text NAME=frm_s[1][1] ></td>
<td><input TYPE=text NAME=frm_s[2][1] ></td>
</tr>
<tr>
<td> Address </td>
<td><input TYPE=text NAME=frm_s[0][1] ></td>
<td><input TYPE=text NAME=frm_s[1][1] ></td>
<td><input TYPE=text NAME=frm_s[2][1] ></td>
</tr>
</table>

and PHP can deal with these multidimensional attributes as
multidimensional variables. However, I find the need to
deal with user input in these forms on the client side and
I cannot figure out how to access such variable names in
javascript.

Has anyone any ideas?

Thank you for your time.

Jul 20 '05 #1
2 1431


Ivan wrote:
In my HTML forms (created by PHP) for attribute
names I have been using multidimensional arrays as illustrated
in the following:

<table>
<tr>
<td> ID </td>
<td> [1661] <input TYPE=hidden Name=frm_s[0][0] Value=1661></td>
<td> [1662] <input TYPE=hidden Name=frm_s[1][0] Value=1662></td>
<td> [1663] <input TYPE=hidden Name=frm_s[2][0] Value=1663></td>


Whatever name you use in HTML, with JavaScript you use
document.forms['formname'].elements['elementname']
to access the control object e.g.
document.forms['formname'].elements['frm_s[0][0]']
Instead of using a string literal inside of the square brackets you can
of course use any Javascript expression constructing that string e.g.
with loop variables i and j
document.forms['formname'].elements['frm_s[' + i + '][' + j + ']']
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2


Martin Honnen wrote:

Whatever name you use in HTML, with JavaScript you use
document.forms['formname'].elements['elementname']
to access the control object e.g.
document.forms['formname'].elements['frm_s[0][0]']
Instead of using a string literal inside of the square brackets you can
of course use any Javascript expression constructing that string e.g.
with loop variables i and j
document.forms['formname'].elements['frm_s[' + i + '][' + j + ']']


Thanks!!

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Charles Banas | last post: by
11 posts views Thread by Joshua Russell | last post: by
2 posts views Thread by Chris | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.