...

View Full Version : Finding the coordinates of Option element relative to scroll bar in a list box



shafi_363
01-09-2006, 11:45 PM
Hi,

I am taking help of coordinates for Drag & drop operation between 2
list boxes Since mouseup event was not helping me in giving the target
element( HTML OPTION Element on which the mouse has been released)

Right now i am calculating the index (at which the dragged item has
to be inserted) by event.clientX, event.clientY. And then

(offset of List box) - ( event.clientY)
index= ---------------------------------------
(height of each item)


This is working in all conditions, except when the list box
contains more items than its size. Because then scrollbar comes into
picture. Then my calculation is going wrong. Is there any remedy to
find the correct index even when there is scroll bar.

Exceptional case:
================
If i specify the size of list box as 10. and then i put 20
items in that list box. Then scroll bar appears. Drag that scrollbar
completely down. Then it will show last 10 items. And after dragging
the item from other list box to this , i released my mouse on 13 th
item. then the item should be inserted at 14 th position. BUT FOR ME
ITS INSERTING AT 4 TH POSITION.


Can anyone guide me to come out of this problem !!!

Thanks a lot
--Shafi

glenngv
01-10-2006, 08:10 AM
I don't think you can get a perfect solution (if at all) for this. Why not just add the option item at the start or end of the list then have an UP or DOWN button to arrange the order?

shafi_363
01-15-2006, 06:22 PM
Hi Glen,

In addition to "reorder buttons support" the user should be given option of doing that through DRAG N DROP. User will follow the way which is convenient.

Are you aware of any DOM variable for HTML Select Element, which gives the postion of scroll bar? May be that could help me out...


Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum