Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding the coordinates of Option element relative to scroll bar in a list box

    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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?

  • #3
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •