473,796 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

working out the order of elements in a containing div

hi all

im looking for help on how you can track the order of elements in a
parent div when these elements are dragable (with scriptaculous)?

I tihnk i need to write a function that is called everytime i drag
something, that works out the order of elements in a div. can anyone
help me with this? how would i iterate over the child elements of a
div retrieving their id's in an array.

May 15 '07 #1
2 1909
ASM
libsfan01 a écrit :
hi all

im looking for help on how you can track the order of elements in a
parent div when these elements are dragable (with scriptaculous)?
Does drag-&-drop change order of these elements, or does that only
change their position ? (styles top, left ... z-index )
I tihnk i need to write a function that is called everytime i drag
something, that works out the order of elements in a div.
Certainly yours elements know themselves where (which position) they
are, you only have to ask them : "where are you ?".
how would i iterate over the child elements of a
div retrieving their id's in an array.

Array of divs direct children of a div

childs = new Array();
var c = document.getEle mentById('myDiv ').getElementsB yTagName('DIV') ;
var k = 0;
for(var i=0; i<c.length; i++)
if('myDiv' == c[i].parentNode.id) {
childs[k] = c[i].id;
k++;
}
alert(childs);

Array of all elements direct children of a div

childs = new Array();
var c = document.getEle mentById('myDiv ').getElementsB yTagName('*');
var k = 0;
for(var i=0; i<c.length; i++)
if('myDiv' == c[i].parentNode.id) {
childs[k] = c[i].id;
k++;
}
alert(childs);
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
May 15 '07 #2
libsfan01 wrote:
hi all

im looking for help on how you can track the order of elements in a
parent div when these elements are dragable (with scriptaculous)?
parentDiv.getEl ementsByTagName ('*') will return all the elements in
order according to the DOM tree. If you want some other order, say
based on spatial position, you'll have to look at the position of each
element and look on the coordinates of whatever reference point suits
(top left or center are two obvious ones).

<URL: http://www.w3.org/TR/DOM-Level-2-Cor...tml#ID-A6C9094 >
I tihnk i need to write a function that is called everytime i drag
something, that works out the order of elements in a div. can anyone
help me with this? how would i iterate over the child elements of a
div retrieving their id's in an array.
getElementsByTa gName returns a NodeList which is similar to an array in
that it has a length property that you can use to iterate over the
collection. It is also live, which an array is not, so you only need to
get a reference to it once and it will reflect the state of the
collection at the instant you access it.
--
Rob
"We shall not cease from exploration, and the end of all our
exploring will be to arrive where we started and know the
place for the first time." -- T. S. Eliot
May 15 '07 #3

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

Similar topics

39
2938
by: Nicolas Fleury | last post by:
In the following example: class MyMetaclass(type): pass class MyBaseType(object): __metaclass__ = MyMetaclass class MyType(MyBaseType): x = 4 y = 5 z = 6 Is there any way to modify MyMetaclass to keep the order of x,y,z somewhere?
7
3101
by: Marcio Rosa da Silva | last post by:
Hi! In dictionaries, unlinke lists, it doesn't matter the order one inserts the contents, elements are stored using its own rules. Ex: >>> d = {3: 4, 1: 2} >>> d {1: 2, 3: 4}
2
28263
by: Alpay Eno | last post by:
Hello all... I'm using asp to get records from an access database, very similar to the way datagrid would work. The title of each column in my table is a link that alternates the sort order between ascending and descending... my problem is that text WILL change its sort order just fine but nubers are not always in order. ie: if sort order is ASC (ascending) I might see 2000, 234, 789 (should be ordered but its not). I'm guessing that ASP...
22
6977
by: Les Juby | last post by:
I am trying to adjust the window/table size of a website (www.worklaw.co.za) which has made use of DIV tags with its settings embedded in an CSS file. The client wants its width and height to adjust according to dynamic screen size, and I have been able to adjust the width to a percentage value which works fine. But if I try do the same with the height it shows some very strange results squashing the field to display about 3 lines.
7
2625
by: Daniel Kabs | last post by:
Hi there, for a long time I've been using tables to layout elements on a web page. Example: Say we have a 2x2 table and I'd like to put text (left aligned) and buttons (right aligned) in the top right table cell. These elements should stay on one line and the table should keep a minimum width in order to prevent wrapping. -------------------------------------------------
9
2166
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service) Hide.dll methods and data I want to remain hidden I have a DLL, Hide.dll, that contains methods that I want to handle for
2
1444
by: Mokita | last post by:
Hello, I am using Set class to remove duplicates from an array. The order in the array is important for my work. After removing the duplicates i create another array containing the elements of the Set, but I realize that the order is really different from the first array. Does anyone know how can I have the order of the Set it was inserted first? The code I am using: // my is the array containing the information, which can can contain...
6
2514
by: Zetten | last post by:
This is going to be a long one, but hopefully that will make it easier to understand. I know I don't like posts with too little detail when I'm searching for help. I am creating a form with which a user can make forms. After filling in basic details like Title, Author, Description, the user can add multiple input fields of different types. This is done in the form of a table, with each row acting for a single input, i.e. input1, input2,...
6
7601
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not work. Please review my work and let me know if you see that one little thing that is throwing me for a loop. HTTPD.CONF # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the...
0
9527
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
10223
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
10172
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
10003
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...
1
7546
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
5441
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
3
2924
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.