473,395 Members | 2,079 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,395 software developers and data experts.

Javascript Childnodes

Hi,

I'm having a problem with Javascript reading childnodes. For some weird reason, javascript will not read the childnodes correctly if I have the form fields in separate <td> tags.

Anyone have any suggestions?

Thanks.

This sample code works:

<form name="myform" id="myform">
<table width=200>
<tr>
<td>
<select name="test">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="button" name="assign" value="Assign User" onclick="javascript:get(this.parentNode);">
</td>
</tr>
</table>
</form>
<table>

But this does not:
<form name="myform" id="myform">
<table width=200>
<tr>
<td>
<select name="assigned_user">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="button" name="assign" value="Assign User" onclick="javascript:get(this.parentNode);">
</td>
</tr>
</table>
</form>
<table>
Oct 9 '06 #1
1 10085
Anei
1
In second case parent node for your button wil be table cell, not 'form' element. You should walk up to the tree until you'll get it:

Expand|Select|Wrap|Line Numbers
  1. while (node.tagName.toLowerCase() != 'form') {
  2.     node = node.parentNode;
  3. }
Something like this.
Jan 5 '07 #2

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

Similar topics

4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
1
by: arun32581 | last post by:
I am developing a page for Mozilla/IE which reads xml data and when the link on the page is clicked it displays the data as a table. The display is controlled by a Javascript. Everything works...
3
by: arun32581 | last post by:
I am developing a page for Mozilla/IE which reads xml data and when the link on the page is clicked it displays the data as a table. The display is controlled by a Javascript. Everything works...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
9
by: Lyners | last post by:
Quick question. I have some java script that looks like this; ...
3
by: Lyners | last post by:
I have a table within a cell of a datagrid. I am doing updates without postback to the server using Javascript. I have everything working, except referencing a table within the datagrid cell. ...
2
by: verci | last post by:
Hi guys, sorry if this seems stupid but I'm a newbie, I'm running Windows XP Pro SP2, IE 7, VS2005, ASP.net 2.0 The problem is that I'm trying to display this news scroller made in a Javascript...
1
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
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...
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
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...
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...
0
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,...

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.