473,233 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

Drag drop prob with javascript

Hi i'm using the below code which i need that when the user clicks on the "drag.gif" the whole div is drag and droped. The code works fine if i put the image out of the table...

any suggention on why its not working?
Expand|Select|Wrap|Line Numbers
  1.     <script type="text/javascript">
  2.             document.onmousedown = MouseDown;
  3.             document.onmousemove = MouseMove;
  4.             document.onmouseup = MouseUp;
  5.  
  6.             N = (document.all) ? 0 : 1;
  7.  
  8.             if (N) 
  9.             {
  10.                 document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
  11.             }
  12.  
  13.             var ob;
  14.             var dv;
  15.  
  16.             function MouseDown(e) 
  17.             {
  18.                 if (N) 
  19.                 {
  20.                     ob = document.layers[e.target.name];
  21.                     X=e.x;
  22.                     Y=e.y;
  23.                     return false;
  24.                 }
  25.                 else 
  26.                 {
  27.                     ob = event.srcElement.parentElement.style;
  28.                     X=event.offsetX;
  29.                     Y=event.offsetY;
  30.                 }
  31.             }
  32.  
  33.             function MouseMove(e) 
  34.             {
  35.                 if (ob)
  36.                 {
  37.                     if (N) 
  38.                     {
  39.                         ob.moveTo((e.pageX-X), (e.pageY-Y));
  40.                     }
  41.                 else 
  42.                 {
  43.                     ob.pixelLeft = event.clientX-X + document.body.scrollLeft;
  44.                     ob.pixelTop = event.clientY-Y + document.body.scrollTop;
  45.                     return false;
  46.                 }
  47.             }
  48.             }
  49.  
  50.             function MouseUp() 
  51.             {
  52.                 ob = null;
  53.             }
  54.  
  55.             function removeEvent()
  56.             {
  57.                 if (document.getElementById('dragContainer') != null)
  58.                 {
  59.                     document.forms[0].removeChild(dv);
  60.                 }
  61.             }
  62.  
  63.             function MsgBox (name, createdDate) 
  64.             {
  65.                 removeEvent();
  66.  
  67.                 dv = document.createElement('div');
  68.                 dv.setAttribute('id',"dragContainer");
  69.                 dv.className="regular";
  70.                 dv.style.position="absolute";       
  71.                 dv.style.position="absolute"; 
  72.                 dv.style.pixelLeft= 500;
  73.                 dv.style.pixelTop = 50 ;
  74.                 dv.style.pixelWidth=10;
  75.                 dv.style.pixelHeight=20;
  76.                 dv.innerHTML="<table cellpadding='0' cellspacing='0'height='200' width='300'><tr><td><img src='drag.gif' OnMouseDown='MU()' OnMouseUp='MU()'/></td><td><img src='close_icon.gif' onclick='removeEvent()' /></td></tr><tr><td  colspan='2' width='100%' bgcolor='#CCCCCC' align='CENTER' valign='MIDDLE' style='height: 76%'><font face='Helvetica,Verdana,Arial' size='3' color='#000066'><b>Name :" + name + "<br>Created on : " + createdDate + "</b></br /></font></td></tr></table>";
  77.  
  78.                 document.forms[0].appendChild(dv);
  79.             }
  80.  
  81.             function chnageText(strText)
  82.             {
  83.                document.getElementById('<%=txtPath.ClientID%>').value = strText;
  84.             }
  85.  
  86.     </script>
Jul 26 '07 #1
2 1243
pbmods
5,821 Expert 4TB
Heya, Talghagin. Welcome to TSDN!

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 26 '07 #2
What do you want your code to do?

When the user clicks on the drag.gif the DIV is draged and when the user realses the mouse button the DIV is dropped were the button was released.

What is your code doing that you don't want it to do? Give an example.
The scrooll bars are int working, i can't click and drag them.

What is your code *not* doing that it is supposed to? Give an example
When the image is placed out of the table example "<div><img src=''drag.gif' /><TABLE...." the div is carried as it should.and when the iamge is part of the table the div doesn't move .

Hope this helps you in helpinh me
and thnak for the welcome :)
Jul 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
5
by: simon_s_li | last post by:
Hi, I am having problems finding out how to drag and drop text from one cell to another in a table in a JSP page. Can someone tell me how I can drag and drop text from one cell to another???...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
17
by: Romulo NF | last post by:
Ive seen some people around the web wondering about a code to reorder table columns using the mouse (drag and drop). Since i had already made one script to reorder table lines (TRs) i decided to...
2
by: ameshkin | last post by:
Hi, I'm working on a drag and drop feature with the scriptaculous javascript library. And I was wondering if someone could help me! :( Here is some test code. Basically, when someone takes...
3
by: crazystone82 | last post by:
Hi friends, i need to drag a file from desktop and drop into web page.actually i had did a JS for dragging the images around the web page,but i dont know how to drag the file and drop it into...
1
by: kidelectric | last post by:
The issue I am having is that I would like to be able to drag-and-drop div elements that have rounded corners.* Since these elements will be dynamically created (including background color), I could...
5
by: Romulo NF | last post by:
Greetings, Im back here to show the new version of the drag & drop table columns (original script ). Ive found some issues with the old script, specially when trying to use 2 tables with...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.