Solved

Javascript Table Cell elements

Posted on 2003-12-01
3
7,438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Echo'd values in dropdowns 6 57
modify change color of text 9 50
How do I add counter to html listbox using jquery 2 44
Slow Down an Animation 3 29
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-…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

734 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