Solved

Javascript Table Cell elements

Posted on 2003-12-01
3
7,429 Views
Last Modified: 2011-10-03
I have a table like:

<table id="tbl_">
    <!-- Looping multiple rows through code
      i is an increment variable
    -->
    <tr>
         <td><input type="hidden" name="hdn[i]" value="1"</td>
         <td>Hello World</td>
    </tr>
</table>

I want to be able to take a find the name of the hidden input in the table cell 0.  Something like:

alert(tbl_.rows[0].cells[0].elementAt[0].name);

is this possible?
0
Comment
Question by:srobia
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
oktexasguy earned 50 total points
ID: 9854246
srobia-

I'm not sure exactly what you're asking for.  Let me know if this helps or if I missed the boat on this one.

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function doIt(){
var theTable = document.getElementById("tbl_");
alert(theTable.rows[0].cells[0].children[0].value);
}
</script>
</HEAD>

<BODY>
<table id="tbl_">
    <!-- Looping multiple rows through code
      i is an increment variable
    -->
    <tr>
         <td><input type="hidden" name="hdn[i]" value="1"/></td>
         <td>Hello World</td>
    </tr>
</table>

<input type="button" value="show hidden value" onclick="doIt()"/>

</BODY>
</HTML>
0
 
LVL 1

Expert Comment

by:oktexasguy
ID: 9854250
oops- to get what you're after you in the function doIt() you can change

...children[0].value
to
...children[0].name
0
 

Author Comment

by:srobia
ID: 9859108
thanks -- that is exactly what I needed to do!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now