Solved

Javascript Table Cell elements

Posted on 2003-12-01
3
7,435 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fix Form size HTML 16 30
Put POST values into cookies. 14 28
null, truthy, falsey confusion 25 28
center navbar (navigation menu) on web page 3 9
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

679 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