Hi There
I am trying to create some javascript to do the following:-
Actually its cool, I posted some stuff, but I think I want to work on it some more, so I have deleted the rest of the post.
Sorry to trouble anyone.
Hi There
I am trying to create some javascript to do the following:-
Actually its cool, I posted some stuff, but I think I want to work on it some more, so I have deleted the rest of the post.
Sorry to trouble anyone.
Hi There
I am trying to create some javascript to do the following:-
Actually its cool, I posted some stuff, but I think I want to work on it some more, so I have deleted the rest of the post.
Sorry to trouble anyone.
Hi
I am trying to make a number of elements on my page draggable using the scriptaculous Draggable library.
I need to make specific div elements on the page Draggable, as I do not want all of the div elements to be so, only a certain group. I therefore need to
1. create a list of all div elements with a particular class name
2. from the list get all those div elements with the same class name and find their id's
3. use the Draggable library to instantiate draggable div elements using the id's from the collection. I have the following:-
var divcollection = document.getElementsByTagName("div").className == "draggable";
for (var i = 1; i<=divcollection.length;i++)
{
var idcollection = divcollection[i].getAttribute("id");
for (var l = 1; l<=idcollection.length;l++)
{
new Draggable ('idcollection[l]', {});
}
}
Any help would be appreciated, I have been trying to make the elements draggable for some time, and dont seem to be getting anywhere.
Your code is going to be out of bound. Array in Javascript is 0-index, not 1-index. Also, you need to read the scriptaculous tutorial about how to do it. I have never used it, but I can at least tell you that you are doing it wrong. You are not supposed to create Draggable object on each character of an ID string. You need to use each element to create it.
The code below is just my guess from whatever I saw from the website. Not sure if you need to put this portion in your window.onload() or not... Still, do not forget to include the javascript library file in your page as well.
var divcollectionraw = document.getElementsByTagName("div");
var divcollection = new Array();
// now clean the div collection before adding draggable object
for (var i=0; i<divcollectionraw; i++) {
if (divcollectionraw[i].className=="draggable") { divcollection.push(divcollectionraw[i] }
}
divcollection.each(
function(item) {
new Draggable(item, {});
}
);
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.