473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HOW to get the parent of text field in a table

Hi all,

I need to access the <TR> element where an input text field is hosted.
I would like to do this client side as i need to hide the TR based on
certain conditions.

The HTML is already written and cannot get to the source because it is
a server side page that we don't have acess to, but we can include
certain javascript snippets.

So the HTML looks something like this by the time i can execute my
javascript function:

<TABLE>
<TR>
<TH nowrap valign="top" class="ms-formlabel"><nobr>Name<font
color="red"> *</font></nobr></TH>
<TD class="ms-formbody"><INPUT TYPE="text" NAME="somefield"
id="idFilename" >
</TD>
</TR>
....

</TABLE>
So the element that i can get to is idFilename but need to hide the
whole TR row based on certain conditions.

Question: is it possible to do that?. can I use some sort of
parentNode or container method to get to the TR?

I would greatly appreciate any help.

thanks in advance.

Sergio
Jul 23 '05 #1
2 7428
On 2 Nov 2004 01:15:30 -0800, Sergio Otoya <se****@winapp.com.au> wrote:
I need to access the <TR> element where an input text field is hosted.
[snip]
Question: is it possible to do that?. can I use some sort of parentNode
or container method to get to the TR?


Yes, use the parentNode property:

var cell, row;

if((cell = inputRef.parentNode) && (row = cell.parentNode)) {
// row now refers to the parent row of the element, inputRef
}

The best way to get inputRef depends upon how the code is called.

[snip]

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Mike,

Thanks very much for your response. It works perfectly.

Sergio.

"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message news:<opsgt6qyiyx13kvk@atlantis>...
On 2 Nov 2004 01:15:30 -0800, Sergio Otoya <se****@winapp.com.au> wrote:
I need to access the <TR> element where an input text field is hosted.


[snip]
Question: is it possible to do that?. can I use some sort of parentNode
or container method to get to the TR?


Yes, use the parentNode property:

var cell, row;

if((cell = inputRef.parentNode) && (row = cell.parentNode)) {
// row now refers to the parent row of the element, inputRef
}

The best way to get inputRef depends upon how the code is called.

[snip]

Hope that helps,
Mike

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeje | last post by:
Hi, I'm trying to detect if an input field is visible or not in order to put the focus inside it (or else it cause th error : "Can't move the focus ot the control because it is invisible, not...
1
by: Filiz Duman | last post by:
Hi, I am opening a pop up window (child) from a parent window. The Child window does show a table with multiple columns and rows, each showing a value, e.g. 9 or 10 or etc. I have the values as...
0
by: Mark Tait | last post by:
Hi - I think I'm getting very tied up here. Using Web Matrix, and have posted in the asp.net forum, with no help unfortunately. I have a table, which has a parent/child relationship with itself....
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
1
by: Kevin Myers | last post by:
Hello, I have a form that contains several sub-forms corresponding to tables which are conceptually children of the main table for the form. On this form, I need to have a button that allows...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
5
by: Michael | last post by:
Hi. I need dinamically calculate input text field based on parent static TD before showing content of input. Please, advice. Michael
1
by: Richard | last post by:
Greetings. I am total newbie to Javascript so what is written below is probably a bunch of cobblers!! Any assistance in correcting my code much appreciated. I wish the popped up child to pass...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.