suzzane2020 Posted March 30, 2007 Share Posted March 30, 2007 Hi, Iam working on drag and drop html control script. Here i have a list of html elements which can be dragged and dropped onto a dropable area. so far so good. But i need to position these elements when i drop them ie. I need to place them wherever i want in the dropable area. hw can i do tht using the div tag. Any help wud be appreciated Thank You Quote Link to comment Share on other sites More sharing options...
micah1701 Posted March 30, 2007 Share Posted March 30, 2007 here is what I would do but i'm just writting this free-hand so it may not work. you should be able to get the idea <style type="css/text"> #movableDiv{ position: absolute; /* original coordinates */ top: 50px; left: 50px } </style> <script type="javascript"> function moveDiv(){ //do some sort of onClick thing to figure out where your mouse is // and where you want the top, left corner of the div to be var newTop = 600; var newLeft = 69; document.getElementById('movableDiv').style.top = newTop + "px"; document.getElementById('movableDiv').style.left = newLeft + "px"; } </script> <div id="movableDiv"> stuff inside div </div> Quote Link to comment Share on other sites More sharing options...
suzzane2020 Posted March 30, 2007 Author Share Posted March 30, 2007 hi, Thanx n yes i got an idea . Struggled a bit but got it to work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.