By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,107 Members | 689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,107 IT Pros & Developers. It's quick & easy.

Is it possible to grab a parent node/element?

P: 76
This is an example of what I'm trying to accomplish but anyway..


<table id="myTable1">
<tr>
<td><input type="checkbox" onClick="doSomething(this)" value="1"/></td>
<td>One</td>
</tr>
<tr>
<td><input type="checkbox" onClick="doSomething(this)" value="2"/></td>
<td>Two</td>
</tr>
</table>


Right now I have some javascript that on click checks to see if the checkbox is being checked or unchecked and runs another function based on this. What I want to do now is to grab the table row and copy its contents to replicate in another table. Basically "You have the following selected" type of thing.

If it's easy to grab a parent node I'll continue with this idea otherwise I'll chuck it and force people to actually possibly remember what they've checked already.
Feb 8 '07 #1
Share this Question
Share on Google+
2 Replies

P: 76
myRow = this.parentNode.parentNode works so nevermind :D
Feb 8 '07 #2

dmjpro
100+
P: 2,476
if want to grab value =============== one or two
then try this code .......

tab_id = document.getElementById('myTable1')
row_no = this.parentElement.parentElement.rowIndex
tab_id.rows[row_no].cells[1].value ==== will be value u want
Feb 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.