PDA

View Full Version : CSS/Javascript Help



ThisNameWillDo!
21-03-2010, 12:46 PM
Hey, I have another problem, this one more javascript. I have a script that allows users to drag and drop certain divs anywhere they like. However, when the page is refreshed, the position is reset to default. Does anyone know how I can make it save the position? Perhaps using cookies or something?

+Rep for any help.

Thank you.

Protege
21-03-2010, 01:25 PM
I wouldn't recommend cookies really. You need the locations to be saved somewhere, and then you will need to reposition them accordingly with the saved data.

ThisNameWillDo!
21-03-2010, 01:47 PM
I wouldn't recommend cookies really. You need the locations to be saved somewhere, and then you will need to reposition them accordingly with the saved data.

Okay then, how would I do that? The current script I have:


<!--;
var pickedUp = new Array("", false);
function getReadyToMove(element, evt) {
pickedUp[0] = element;
pickedUp[1] = true;
}

function checkLoadedObjects(evt) {
if (pickedUp[1] == true) {
var currentSelection = document.getElementById(pickedUp[0]);

currentSelection.style.position = "fixed";
currentSelection.style.top = (evt.clientY + 1) + "px";
currentSelection.style.left = (evt.clientX + 1) + "px";
}
}

function dropLoadedObject(evt) {
if (pickedUp[1] == true) {
var currentSelection = document.getElementById(pickedUp[0]);
currentSelection.style.position = "fixed";
currentSelection.style.top = (evt.clientY + 1) + "px";
currentSelection.style.left = (evt.clientX + 1) + "px";
pickedUp = new Array("", false);
}
}

//-->

Want to hide these adverts? Register an account for free!