473,653 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

find form elements in particular TableRow

Hi, As you can see from the code below I have a simple js function
called getFormElements inTableRow(rowN ame). rowName is the ID of the
tableRow. I just want to use js to find the child ID's of all the form
elements in that particular tableRow. What am I doing wrong?
<table><tr id="where12" style="DISPLAY: none">
<td><select name="parameter 12" id="parameter12 ">
<option value="1">casen umber</option>
<option value="2">analy st</option>
</select>
<div class='button'>
<A href='#' onclick="javasc ript:getFormEle mentsinTableRow
('where12');"> DELETE ROW </A>
<div></td></tr></table>

<Script jang=javascript >
function getFormElements inTableRow(rowN ame){

var nodeList = document.getEle mentById(rowNam e);

for (var i = 0; i < nodeList.length ; i++)
{
var node = nodeList[i];
alert(node.id);
}

}
<script>

Jul 23 '05 #1
2 6588
th************* ****@yahoo.com wrote:
Hi, As you can see from the code below I have a simple js function
called getFormElements inTableRow(rowN ame). rowName is the ID of the
tableRow. I just want to use js to find the child ID's of all the form
elements in that particular tableRow. What am I doing wrong?
<table><tr id="where12" style="DISPLAY: none">
<td><select name="parameter 12" id="parameter12 ">
<option value="1">casen umber</option>
<option value="2">analy st</option>
</select>
<div class='button'>
<A href='#' onclick="javasc ript:getFormEle mentsinTableRow
('where12');"> DELETE ROW </A>
There is no need for the javascript pseudo-protocol, and your onclick
should return false to stop browsers from going back to the top of the
page.

<A href='#' onclick="
getFormElements inTableRow('whe re12');
return false;
"> DELETE ROW </A>

Even better would be to not subvert an A element and use something more
suitable - span, div, input type=button, button, etc.
<div></td></tr></table>
^-- Closing tag?

</div>...

<Script jang=javascript >
I'll assume that is a copy/paste error. The 'lang' attribute never
existed for script elements, there is a depreciated 'language'
attribute, but type is required:

<script type="text/javascript">
function getFormElements inTableRow(rowN ame){

var nodeList = document.getEle mentById(rowNam e);
getElementById( ) returns a reference to an element. In this case,
'nodeList' will be a reference to the TR element - it is not an array
or collection. nodeList.length will be 'undefined'.

Using what are (to me) more suitable variable names:

function getFormElements inTableRow( rowID ){
var r = document.getEle mentById(rowID) ;
var rA = r.getElementsBy TagName('*');

for (var i = 0; i < nodeList.length ; i++)
{
var node = nodeList[i];
alert(node.id);
}
Here is an alternative that shows the elements and their ID if they
have one:

var x, i=0;
while ( x = rA[i++] ) {
alert( x.nodeName + '\n' +
((x.id)? 'id: ' + x.id : ' no ID'));
}
}
<script>
Closing tag?

</script>


If you want just the form elements, you'll have to sift through the
collection in rA. If this is for more than casual interest, you should
feature test getElementById and getElementsByTa gName before using
them and you may also want to add support for document.all.

Here's the full script:

<script type="text/javascript">

function getFormElements inTableRow( rowID ){
var r = document.getEle mentById( rowID )
var rA = r.getElementsBy TagName('*');
var x, i=0;

while ( x = rA[i++] ) {
alert( x.nodeName + '\n' +
((x.id)? 'id: ' + x.id : 'no ID') );
}
}
</script>
--
Rob
Jul 23 '05 #2
Thanks Rob for working through my assored typos and brain farts. It
works beautifully now.

Jul 23 '05 #3

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

Similar topics

8
12610
by: Stan Brown | last post by:
http://oakroadsystems.com/nonce/zonk.htm (12 lines) > http://validator.w3.org/check?charset=%28detect+automatically%29&doctype=Inline&uri=http%3A%2F%2Foakroadsystems.com%2Fnonce%2Fzonk.htm&outline=x The W3C validator says "INPUT is not allowed here". I'm sure my mistake is really obvious, but I just can't see it. I'd appreciate another pair of eyes pointing out the problem. For convenience, here's the entire file. I've stripped it...
6
2142
by: francisco lopez | last post by:
ok , first of all sorry if my english is not so good, I do my best. here is my problem: I don´t know much javascript so I wrote a very simple one to validate a form I have on my webpage. could you please have a look at the following script: ------------------------------------------------------------
4
1412
by: Jeremy Ames | last post by:
I have a problem with one of connections using the wrong connection string. I have a form that has three late bound sql connections. Each connection is local to the function that it used in. The problem I am having is that the last connection uses a different username and password to sign in. By the time that the third connection is opened, the other two connections have been opened, closed, and disposed. What is happening is that the third...
3
1383
by: Jeremy Ames | last post by:
Can someone please help with this? Unfortunately, that did not work. "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:uwMY%23fquDHA.2308@TK2MSFTNGP11.phx.gbl... Hi Jeremy, Please try using 127.0.0.1 instead of (local) in the connection string: cnTask.ConnectionString="Data Source=127.0.0.1;" +
6
2640
by: hb | last post by:
Hi, I have a page bill.aspx and its code-behind bill.aspx.cs. On bill.aspx I have: === Select a month: <asp:dropdownlist runat="server" id="lstDate" autopostback="True" /> <br> <asp:table runat="server" id="tabBill" /> <br>
2
12354
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page contains multiple panels within the form. The panels appear at different times - for our argument, let's say panel 1 appears first, users clicks a submit button and then panel 1 disappears and panel 2 appears, etc. When clicks on the submit button...
3
1805
by: Tyler Carver | last post by:
I am trying to use some dynamic controls that are built and then added to tables. The problem that I am having is the timing of when I can populate the controls and have the state remain after a postback. The main question would be this: Why does this work for maintaining state after a postback for dynamic controls: myText = new Label(); myText.ID = "myText";
4
3197
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively search a parent element(in my case a <table>) and search for elements of a certain type (<input>, <textarea>, etc) and perform operations on them. I've done some initial googling and found PLENTY of samples of disabling all form items, but I...
2
2964
by: prao2005 | last post by:
My XML Code <DBE:Attribute name="Test1" type="Table"> <DBE:Table> <DBE:TableHeader> <DBE:TableColumn>t1</DBE:TableColumn> <DBE:TableColumn>t2</DBE:TableColumn> <DBE:TableColumn>t3</DBE:TableColumn> <DBE:TableColumn>t4</DBE:TableColumn>
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.