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
 </form>

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!

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

document.forms[0].y.value = 'yourRestoredValue';

Btw, Java is totally different from Javascript. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.