Hi,I am using dhtml goodies js file for drag and drop.i have to pass sourceid for the function in js file.

        addSource : function(sourceId,slideBackAfterDrop,xAxis,yAxis,dragOnlyWithinElId,functionToCallOnDrag)
    {
            if(!functionToCallOnDrag)functionToCallOnDrag=false;
            if(!this.dragDropSourcesArray)this.dragDropSourcesArray = new Array();
            if(!document.getElementById(sourceId))alert('The source element with id ' + sourceId + ' does not exists');
            var obj = document.getElementById(sourceId);

            if(xAxis!==false)xAxis = true;
            if(yAxis!==false)yAxis = true;

            this.dragDropSourcesArray[this.dragDropSourcesArray.length]  = [obj,slideBackAfterDrop,xAxis,yAxis,dragOnlyWithinElId,functionToCallOnDrag];    
            obj.setAttribute('dragableElement',this.dragDropSourcesArray.length-1);
            obj.dragableElement = this.dragDropSourcesArray.length-1;

        }

        I have to pass id for dynamically created elemets so for that i did a code like this,



     <div  class="dragableBox" ondrag="add1(this.id)"   id="<%=rs_list_task1.getString("task_id")%>" >
     function add1(id)
{
var dragDropObj = new DHTMLgoodies_dragDrop();
dragDropObj.addSource(id,true,true,true,false,'onDragFunction');

}

if i give static like this dragDropObj.addSource('324',true,true,true,false,'onDragFunction'); its working..how could i pass id of dynamically created div's to this function...

It depends on how you pass in the id. By the way, are you using Ruby or JSP? If so, you need to escape the double quote id="<%=rs_list_task1.getString(\"task_id\")%>"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.