473,659 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change id of element in DOM, IE7...

I have some javascript to rearrange a list of elements...

1) Each element (div) is initially given a unique id, the same id of
the database record the element represents.
2) User "moves" element from slot 3 to slot 6, for example (result: 3-
>6, 6->5, 5->4, 4->3).
3) I copy the innerHTML of each div (3-6) into an array.
4) I set the innerHTML of each div (3-6) to now contain the
appropriate content from the array.
5) I update the id's of each div (3-6)...

Seems simple enough for me, and seems to work flawlessly in Firefox...

IE7, however, seems to forget the effects of step 5, so on the second
"move," step 4 puts the innerHTML's in the wrong slots...grrrrrr ...any
ideas?
Jun 27 '08 #1
2 1937
Stephen Durkin wrote:
I have some javascript to rearrange a list of elements...

1) Each element (div) is initially given a unique id, the same id of
the database record the element represents.
2) User "moves" element from slot 3 to slot 6, for example (result: 3-
>6, 6->5, 5->4, 4->3).
3) I copy the innerHTML of each div (3-6) into an array.
4) I set the innerHTML of each div (3-6) to now contain the
appropriate content from the array.
5) I update the id's of each div (3-6)...

Seems simple enough for me, and seems to work flawlessly in Firefox...

IE7, however, seems to forget the effects of step 5, so on the second
"move," step 4 puts the innerHTML's in the wrong slots...grrrrrr ...any
ideas?
You should move the elements, not their content.

slot[5].appendChild(sl ot[2].firstChild);

That is, provided that the `firstChild' property refers to the element
to be moved, and not to a whitespace text node. You may want to use
slot[2].getElementsByT agName("*")[0] or another reference instead.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Jun 27 '08 #2
On Apr 30, 11:52 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Stephen Durkin wrote:
I have some javascript to rearrange a list of elements...
1) Each element (div) is initially given a unique id, the same id of
the database record the element represents.
2) User "moves" element from slot 3 to slot 6, for example (result: 3-
6, 6->5, 5->4, 4->3).
3) I copy the innerHTML of each div (3-6) into an array.
4) I set the innerHTML of each div (3-6) to now contain the
appropriate content from the array.
5) I update the id's of each div (3-6)...
Seems simple enough for me, and seems to work flawlessly in Firefox...
IE7, however, seems to forget the effects of step 5, so on the second
"move," step 4 puts the innerHTML's in the wrong slots...grrrrrr ...any
ideas?

You should move the elements, not their content.

slot[5].appendChild(sl ot[2].firstChild);

That is, provided that the `firstChild' property refers to the element
to be moved, and not to a whitespace text node. You may want to use
slot[2].getElementsByT agName("*")[0] or another reference instead.

PointedEars
Thanks for the help. I implemented this approach, and guess what? It
seems flawless in Firefox but it's broken in IE7!! The failing
behavior is different now. I don't know why but I'll post more
details tomorrow. Anonymous should take down Microsoft after the CoS
dust settles.

Jun 27 '08 #3

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

Similar topics

4
23948
by: michael | last post by:
I have an html text string within a div, eg.: <div id="example">Text text text</div> I know its easy to change styles by using getElementById - for example: document.getElementById("example").style.fontColor="#ff0000"; But what way(s) are there to change the actual text content itself on the page dynamically, from "Text text text" to"Bla bla bla" ?
2
2968
by: Isz | last post by:
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all outputs into a nice XML file for the purpose of populating a flash navigation menu. <NewDataSet> <mainMenu_category menu_name="Home" menu_ID="1"> <menu menu_ID="1" />
5
11163
by: VA | last post by:
Mozilla-based browsers have watch and unwatch methods to detect change in value of form elements (or any Javascript variables really). IE doesn't support this. Is there a a reliable cross-browser way alternative to this? Something that will let me detect a change in value for a form element and trigger my own callback function upon change? Hopefully, something that is generic enough to be called as "MyWatch(element)"!
2
10057
by: Philipp | last post by:
Hi, I wrote a small c# programm, which generates an xml-string by serializing a class and sends it to a server. Now I want to change some values in that xml-string. The only way for me to do that might be, to deserialize it, change the particular attribute and serialize it again, to finally save it on my harddisk. But I believe, that there is a more convenient way to do this, since it is also possible to append an element...
7
2086
by: David | last post by:
Hi, I'd really appreciate any help. Im trying to change a label over and over again. I can change it the first time, by using the following code, however it never works again, how can i do this so it uses the same element name? This is driving me insane. On the second call to var spanElm = document.getElementById("FirstNameLengthLabel"); spanElm is set to NULL. <script language=javascript>
6
12759
by: libsfan01 | last post by:
hi all! is it possible to change an element type with javacript for example onclick to change a text box to a hidden element or to a textarea? kind regards marc
4
6478
by: Dan | last post by:
H, i want to use for one specific application the default membership provider as defined by default in machine.config, except one element: i want to use requiresUniqueEmail="false" instead of the default configuration in machine.config (which is set on "true"). So i did this in the web.config of the application: <membership defaultProvider="MyMembershipProvider"> <providers>
5
13186
by: yhlove | last post by:
Hi I'm trying to change element in xml file as described below: the xml file: ---------------- <MyProg> <Path>test1</Path> </MyProg>
3
9625
by: rlueneberg | last post by:
I want to change the color of an "a" child element inside a table cell via javascript. Is there any way to do that? Ps: there is no id assigned to child elements. I would like to discover the child element and change its color from the parent element if possible. <script type="text/javascript"> function HightLightCell(mycell, mybgcolor) { mycell.bgColor=mybgcolor; }
15
3711
by: Sunny | last post by:
Hi, I can change the lement opacity in IE using. abc.style.filter = 'alpha(opacity=' + 10 + ')'; But this dont work in firefox, In firefox it throws error. How I can change the opacity of an element in Firefox.
0
8428
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
8337
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
8851
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
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.