Solved

Javascript Table Cell elements

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

706 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

21 Experts available now in Live!

Get 1:1 Help Now