By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

passing a variable

100+
P: 178
Hi,

I have added in a drag and drop function from a tutorial and it works well. The problem I am having is that I need my variable g_objName to be associated with dragobj. Has anyone any ideas?

Expand|Select|Wrap|Line Numbers
  1. function showObject (){
  2.     if (request.readyState == 4) {
  3.     var returned = request.responseText;
  4.     var splitResult = returned.split(" ");
  5.     var h = splitResult[0];
  6.     var w = splitResult[1];
  7.     h = h/5;
  8.     w = w/5;
  9.  
  10.     cv = document.getElementById("canvas");
  11.     var newObject = document.createElement('div');
  12.     newObject.Class = g_objName;
  13.     newObject.id = "newObject";
  14.     newObject.innerHTML = g_objName;
  15.     newObject.style.height = h;
  16.     newObject.style.width = w;
  17.     newObject.onmousedown=function(){grab(this);}    
  18.     cv.appendChild(newObject);
  19. }
  20.  
  21. function grab(context)
  22. {
  23.   document.onmousedown = falsefunc; // in NS this prevents cascading of events, thus disabling text selection
  24.   dragobj = context;
  25.   dragobj.style.zIndex = 10; // move it to the top
  26.   document.onmousemove = drag;
  27.   document.onmouseup = drop;
  28.   grabx = mousex;
  29.   graby = mousey;
  30.   elex = orix = dragobj.offsetLeft;
  31.   eley = oriy = dragobj.offsetTop;
  32.   update();
  33. }
Jul 11 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Associated in what way? How are you planning to use that variable? Is it just a string? Note that Class should be className (case-sensitive).
Jul 11 '08 #2

Post your reply

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