473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1510


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
11
by: Joshua Russell | last post by:
Hi, I wish to parse an XML file into some sort or array or multidimensional storage. The XML file is as follows (without any parent tags just to give you an idea of the structure)... <Ship...
2
by: phattymatty | last post by:
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already been sorted in the array using a...
2
by: Chris | last post by:
I can't figure out how to handle multidimensional arrays with json created with ajax/php e.g. {"452":{"name":"chris","age":"21"},"798":{"name":"sam","qty":"22"}} I use the following code for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.