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
https://forums.phpfreaks.com/topic/155734-create-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.