Hey, does anyone know how i can make it so i can drag an object then i can press save and it will save the x and y cordinates to mysql?

Hey, does anyone know how i can make it so i can drag an object then i can press save and it will save the x and y cordinates to mysql?
Post an example of the JavaScript app. you're using.
kinda quit.
I don't want to make a new thread on this.
Im using Scriptaculous (think thats how you spell it)
I can't make it drag, I can do sortables, etc. But how can I limit the drag in a specific table/div.
Also how can I export the x,y of the div?
this is what i have so far
PHP Code:<style>
<!--
.dragme{position:relative;}
-->
</style>
<script language="JavaScript1.2">
<!--
var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var x,y;
var dobj;
function movemouse(e)
{
if (isdrag)
{
dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
dobj.style.top = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
return false;
}
}
function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
while (fobj.tagName != topelement && fobj.className != "dragme")
{
fobj = nn6 ? fobj.parentNode : fobj.parentElement;
}
if (fobj.className=="dragme")
{
isdrag = true;
dobj = fobj;
tx = parseInt(dobj.style.left+0);
ty = parseInt(dobj.style.top+0);
x = nn6 ? e.clientX : event.clientX;
y = nn6 ? e.clientY : event.clientY;
document.onmousemove=movemouse;
return false;
}
}
document.onmousedown=selectmouse;
document.onmouseup=new Function("isdrag=false");
//-->
</script>
<?
ob_start(); //Allows Cookies
include("config.php"); //Connects to Database
?>
<?
if($logged[username]){
$sql="SELECT * FROM uses_furni WHERE username = '$logged[username]' ORDER BY `id`";
$result=mysql_query($sql); //Selects the items from the database
while($rows=mysql_fetch_array($result)){ //Puts the info in an array
echo("<div style=\"position: absolute; width: 28px; height: 30px; z-index: 1; left:$rows[ypos] px; top:$rows[xpos] px;\" id=\"$rows[id]\">
<p><img src=\"$rows[itemimage]\" class=\"dragme\"></div>");
$query = mysql_query("Update `uses_furni` Set `xpos` = '$x', `ypos` = '$y' Where `id` = '$image'") or die(mysql_error());
}
}
?>
id like to make it so theres a save button and it saves the x and y cordinates to that item.
That code was on TT.
I've got it:
http://www.dynamicdrive.com/dynamicindex4/image3.htm
Its the script were u drag Images Or DIV Boxs! Enjoy!
Soon To Be Released....
No point "Scott" :rolleyes:
Better than saying something newby like "point" I suppose.
phpme, that is just drag and drop and not saved so you can't come back to it how you left it. I would like this aswell, one of the best scripts people could have.
Does it have to be saved permanently, or could it be saved in a cookie (positions would be lost once the user clears their cookies)? It would be easier and more efficient to use cookies, if that's a viable option.
kinda quit.
Want to hide these adverts? Register an account for free!