Log in

View Full Version : Alerting x/y



Romanity
08-05-2007, 03:59 PM
Right, drag and drop works fine. I made a function so when you click save it runs a function to get the x&y co-ordinates... and for now alert them so i know its working.


<?php
ob_start();
include("config.php");
function save()
{
$topval = document.getElementById('example').style.top;
$leftval = document.getElementById('example').style.left;
echo("
<script>
alert ('$topval $leftval')
</script>
");
}
?>
<html>
<head>
<title>OurHabbo</title>
<link href="ourhabbo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="dom-drag.js"></script>
</head>
<body class='content'>
<span class='contentHeading'>Drag & Drop Practise</span><br><Br>
<img id="example" src="lips_small.gif" style="position: relative" />
<script type="text/javascript">
Drag.init(document.getElementById("example"));
</script>
<a href='#' onClick='javascript: save();return true'>Save</a>
</body>
</html>

Theres the coding, but when i click Save, it wont alert the co-ordinates.

Splinter
08-05-2007, 04:07 PM
Thats php mate.. try javascript :S

Romanity
08-05-2007, 04:10 PM
Kk, so how would i do it =]

Luckyrare
08-05-2007, 04:14 PM
your mixing both php functions with javascript functions, interesting...

Romanity
08-05-2007, 04:15 PM
Im far from good with functions (A)

Sooooo, how would i go about getting the position of "example" and then alert the user with them?

Invent
08-05-2007, 04:35 PM
<script>
function save()
{
var top = document.getElementById('example').style.top;
var bot = document.getElementById('example').style.left;

alert(top bot)
}
</script>

I think?

Drompo
08-05-2007, 04:36 PM
<?php
ob_start();
include("config.php");
function save()
{
$topval = document.getElementById('example').style.top;
$leftval = document.getElementById('example').style.left;
?>
<script>
alert ("<?php echo "$topval $leftval"; ?>")
</script>
<?
}
?>
<html>
<head>
<title>OurHabbo</title>
<link href="ourhabbo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="dom-drag.js"></script>
</head>
<body class='content'>
<span class='contentHeading'>Drag & Drop Practise</span><br><Br>
<img id="example" src="lips_small.gif" style="position: relative" />
<script type="text/javascript">
Drag.init(document.getElementById("example"));
</script>
<a href='#' onClick='javascript: save();return true'>Save</a>
</body>
</html>

Romanity
08-05-2007, 04:51 PM
None of the codes seem to code... could it be the save link aswell as the coding?

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