View Full Version : Write to excel

12-07-2006, 05:53 PM
I'm trying to do a web with images . And I want when the user click any of the images . Send/store the image location(X,Y) on the form the hight and the width to excel or .csv file.
Or at least popup the information to the user.
Help will be very appritiated.

12-07-2006, 06:09 PM
Well you will need a form to write the the excel or csv file. You can get the XY values of the image by adding this in between your head tags

<script type="text/javascript">
function setClick()
var theimgs = document.getElementsByTagName('img');
for(var i = 0; i < theimgs.length; i++)
var el = theimgs[i];
el.onclick = function()
alert('The image with src="'+el.getAttribute('src')+'" is located at following coordinates:\nX = ' + el.offsetLeft + 'px\nY = ' + el.offsetTop + 'px');
window.onload = setClick;
Then just click on any image and you get the alert.