faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How can i save a div absolute position into a mysql table with js & php? thanks in advance

Apr 7th, 2008 23:32
ha mo, Jean-Bernard Valentaten, Facundo Pagani,


You will have to call a php-document to which you pass the left and 
top coordinates via the querystring (alternatively you could use a 
form that passes the coordinates via POST method).
function passCoords(x, y)
{
  var myURL = 'http://www.mysite.com/myscript.php?left=' + x + 'top=' 
+ y;
  window.open(myURL);
}
function getCoords(elementID)
{
  var x;
  var y;
  with (document.getElementById(elementID).style)
  {
    x = left;
    y = top;
  }
  passCoords(x, y);
}
Well, that is just one possibility to do it and it won't get the 
correct coordinates if the div is not positioned abolute.
If you have a relative positioned element (div, ...) I guess there is 
no realistic way to do the job (well you could write a function that 
iterates through the DOM-tree of your document, but that'll be a heck 
load of work).
HTH,
Jean
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com