Jump to content

Create Array


AE117

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.