AE117 Posted April 26, 2009 Share Posted April 26, 2009 I hope im posting this in the right section but heres what I want to happen. I have javascript that is used for a drag and drop feature however for every item you want to drop you have to add the code in manually. Is it possible for the javasript to build an array off of a certain class of div tags ? Here is the code <script type="text/javascript"> // Custom drop actions for <div id="dropBox"> function dropItems(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('textarea').innerHTML; if(html.length>0)html = html + '<br>'; html = html + 'Item with id="' + idOfDraggedItem+'" dropped'; document.getElementById('textarea').innerHTML = html; } // Custom drop actions for <div id="dropBox2"> function dropItems2(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('dropContent2').innerHTML; if(html.length>0)html = html + '<br>'; html = html + 'Item "' + document.getElementById(idOfDraggedItem).innerHTML + '" dropped'; document.getElementById('dropContent2').innerHTML = html; } var dragDropObj = new DHTMLgoodies_dragDrop(); [color=red]dragDropObj.addSource('box1',true);[/color] // Make <div id="box1"> dragable. slide item back into original position after drop dragDropObj.addSource('box3',true); // Make <div id="box3"> dragable. slide item back into original position after drop dragDropObj.addSource('box4',true); dragDropObj.addSource('box5',true); // Make <div id="box4"> dragable. slide item back into original position after drop dragDropObj.addTarget('dropBox','dropItems'); // Set <div id="dropBox"> as a drop target. Call function dropItems on drop dragDropObj.addTarget('dropBox2','dropItems2'); // Set <div id="dropBox2"> as a drop target. Call function dropItems2 on drop dragDropObj.init(); </script> the part that would be the array is the var dragdrop the elements under it dragDropObj.addsource('box#', true); I dont even know if this is possible so let me know Im not good with javascript Thanks Quote Link to comment Share on other sites More sharing options...
gnawz Posted April 27, 2009 Share Posted April 27, 2009 You can build an array of anything. 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.