473,394 Members | 1,703 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,394 software developers and data experts.

insertBefore IE BUG:

adarshtp
Hi all,

i have a Javascript function as shown:

Expand|Select|Wrap|Line Numbers
  1. function move_row(tr_id,position){
  2.         var parentTable = document.getElementById("TABLE");
  3.         var table_length = parentTable.rows.length;
  4.         if(parentTable.nodeName != 'TBODY')
  5.              parentTable = parentTable.getElementsByTagName('TBODY')[0];
  6.         if(parentTable.nodeName != 'TBODY')
  7.             return false;
  8.  
  9.         if(position=='up'){
  10.             var x = document.getElementById(1);
  11.             var y = document.getElementById(0);
  12.  
  13.             if(x && y){
  14.  
  15.                 parentTable.insertBefore(x, y);
  16.  
  17.  
  18.             }
  19.  
  20.         }
  21.  
  22.         else{
  23.  
  24.             var x = document.getElementById(1);
  25.             var y = document.getElementById(2);
  26.  
  27.             if(x && y){
  28.  
  29.              parentTable.insertBefore(y, x);
  30.  
  31.             }
  32.         }
  33.  
  34.     }

this is a function to swap 2 rows of a table. The problem is that after 2 swapping a JS exception is occuring saying that "invalid Argument". (ie the argument passed to the insertBefore). Can anyone help me??????


This bug is only with IE(tested on IE7). Firefox has no bugs on this case...
Mar 8 '07 #1
2 7505
acoder
16,027 Expert Mod 8TB
Welcome to TSDN (thescripts.com).

Post your table code too (in HTML code tags <>).
Mar 8 '07 #2
Hi,

I got the solution for this bug:


instead of using parentTable.insertBefore(x,y) we can use y.parentNode.insertBefore(x,y). This will surely solve the bug.... :)


Regards
Adi
Mar 8 '07 #3

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

Similar topics

3
by: Rutger Claes | last post by:
Code and problem are from PHP5: When I execute the following piece of code, the DomException is thrown with a message: Not Found Exception. I assume this means that the node I extracted from the...
3
by: Dante | last post by:
Tonight I started writing a script that places a "Copy All" link before every PRE tag. The link would copy the code in the pre tag. I can't get this script to work. Can anyone help me? Here is my...
1
by: Nicole Schenk | last post by:
Client-side problem scripting problem. I have a table of about 300 rows with many columns. User chooses to sort on one column. Sort is very fast (I do this by extracting the column data along with...
5
by: Derek Basch | last post by:
Can anyone tell me why I cant insertBefore() objects that are selected using getElementById()? <html> <head> </head> <body> <p id="heading1"></p>
2
by: e michael brandt | last post by:
I am frustrated. It appears that one can not use insertBefore to insert an A node before a DL node. Is that really true? I *am* able to insert before a <p id="hh"> tag, but not before a <dl...
2
by: Janis Papanagnou | last post by:
This is partly a repost that was maybe too buried to be seen. Sorry for that. I thought it would be an easy to be answered question, but I may be wrong... I wanted to _insert_ cloned table row...
2
by: ashishda | last post by:
I am using a AJAX script to retrieve XML data and then append new <select> options in my table. I see that the appendChild() works fine, but the insertBefore() fails. If however, I have both...
3
by: masterofzen | last post by:
I've been playing around with this for a while. I bet the answer is pretty obvious, but I'm just not seeing it. I'm also reasonably certain I've run into this problem before. I'm trying to...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.