473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Help please!

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:
Expand|Select|Wrap|Line Numbers
  1.     function getPosition(element) {
  2.         var left = 0;
  3.         var top = 0;
  4.         if(element.offsetParent) {
  5.             while(element) {
  6.                 left += element.offsetLeft;
  7.                 top += element.offsetTop;
  8.                 element = element.offsetParent;
  9.             }
  10.         }
  11.         return {offsetLeft: left, offsetTop: top};
  12.     }
  13.  
  14.     var element = document.getElementById('elem');
  15.     var pos = getPosition(element);
  16.     document.Show.X.value = pos.offsetTop;
  17.     document.Show.Y.value = pos.offsetLeft;
  18.     return true
  19.     }
Here's the HTML:
Expand|Select|Wrap|Line Numbers
  1. <div id="elem">My Element</div>
  2. <form name="Show">
  3. <input type="text" name="X" value="0" size="4"> X<br>
  4. <input type="text" name="Y" value="0" size="4"> Y<br>
  5. </form>
Can someone please help me fix my code.. I can't seem to get the values from the java into the form.
Mar 1 '09 #1
1 1246
JosAH
11,448 Expert 8TB
This is not Java; this is Javascript and both languages haven't much in common. Do you want me to move your question to the Javascript forum?

kind regards,

Jos (moderator)
Mar 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
1
by: the_proud_family | last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com I can't get the ball to go up right side and then I need it to turn around and keep turning until velocity=0 I have been at it for the ...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
12
by: Christo | last post by:
borland c++ 5.01 character constant must be one or two characters long get this when compiling my first c++ program can anyone out there help? it is highlighting this line as the problem ...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
17
by: JT | last post by:
Help me the following C++ question: Write a program to help a local bookshop automate its billing system. The program should do the following: (a)Let the user enter the ISBN, the system will...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
2
by: =?Utf-8?B?U2NvdHRSYWREZXY=?= | last post by:
I'm creating a doc project for my c# program. I've done this before but this time sonething is wrong. I build my doc project and is succeeds but when I open the help file, there is no documentation...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.