Hi, I have a question about Java. I'm really new to Java so this is not something I'm familiar with..
My question is, how do I get the values of pos.offsetTop and pos.offsetLeft to show up in my input box??

Here is the java code:

function getPosition(element) {
 var left = 0;
 var top = 0;
 if(element.offsetParent) {
 while(element) {
 left += element.offsetLeft;
 top += element.offsetTop;
 element = element.offsetParent;
 return {offsetLeft: left, offsetTop: top};

 var element = document.getElementById('elem');
 var pos = getPosition(element);
 document.Show.X.value = pos.offsetTop;
 document.Show.Y.value = pos.offsetLeft;
 return true

Here's the HTML:

My Element
 <form name="Show">
 <input type="text" name="X" value="0" size="4"> X
 <input type="text" name="Y" value="0" size="4"> Y

Can someone please help me fix my code.. I can't seem to get the values from the java into the form.

Thanks so much!

8 Years
Discussion Span
Last Post by nav33n

You can give all the restored variable (or values) in your textbox by simply doing this

document.forms[0].y.value = 'yourRestoredValue';
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.