473,403 Members | 2,293 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,403 software developers and data experts.

Position div next to element

I want to position an absolutely positioned div 75px above the button
clicked on. The following is what I have so far, but as you can tell
it needs more work. I want it positioned in relationship to the button
within the window, not the entire screen...and scrolling the window
shouldn't effect it. Just need some pointers please.

<script type="text/javascript">
function showEmployee(elm,x,y){
if(document.getElementById('awardDiv')){
var myElm=document.getElementById('awardDiv');
myElm.style.display='block';
myElm.style.left=(x - myElm.clientWidth/2) +'px';
myElm.style.top=(y + 25) +'px';
}
}
</script>
<input type="button" name="myButton" value="Select Another Employee"
onclick="showEmployee(this,event.clientX,event.cli entY)">

Apr 13 '06 #1
2 1853

johkar wrote:
I want to position an absolutely positioned div 75px above the button
clicked on. The following is what I have so far, but as you can tell
it needs more work. I want it positioned in relationship to the button
within the window, not the entire screen...and scrolling the window
shouldn't effect it. Just need some pointers please.

<script type="text/javascript">
function showEmployee(elm,x,y){
if(document.getElementById('awardDiv')){
var myElm=document.getElementById('awardDiv');
myElm.style.display='block';
myElm.style.left=(x - myElm.clientWidth/2) +'px';
myElm.style.top=(y + 25) +'px';
}
}
</script>
<input type="button" name="myButton" value="Select Another Employee"
onclick="showEmployee(this,event.clientX,event.cli entY)">


Where is awardDiv? Does it have styles applied from a stylesheet?

Have you tried the positioning in an HTML document that does not use
JavaScript so that you can get the CSS would like to implement with
JavaScript correct first?

Peter

Apr 13 '06 #2

pe**********@gmail.com wrote:
johkar wrote:
I want to position an absolutely positioned div 75px above the button
clicked on. The following is what I have so far, but as you can tell
it needs more work. I want it positioned in relationship to the button
within the window, not the entire screen...and scrolling the window
shouldn't effect it. Just need some pointers please.

<script type="text/javascript">
function showEmployee(elm,x,y){
if(document.getElementById('awardDiv')){
var myElm=document.getElementById('awardDiv');
myElm.style.display='block';
myElm.style.left=(x - myElm.clientWidth/2) +'px';
myElm.style.top=(y + 25) +'px';
}
}
</script>
<input type="button" name="myButton" value="Select Another Employee"
onclick="showEmployee(this,event.clientX,event.cli entY)">


Where is awardDiv? Does it have styles applied from a stylesheet?

Have you tried the positioning in an HTML document that does not use
JavaScript so that you can get the CSS would like to implement with
JavaScript correct first?

Peter


Thanks for the reply. I actually realized from another post that I
needed to put a relative positioned div around my absolute positioned
div and then I didn't need to worry about the x and y position onclick.

Apr 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yereth | last post by:
Hi again, still working on my xslt program and I ran into another problem. There is a file which a contains the following structure: <key>1</key> <dict>         ... </dict> <key>2</key>
1
by: Eshrath Ali Khan | last post by:
Hi, I have a requirement where I am transforming a XML into a html using an XSL. I need to create a object for the each and every occurrence of an element named "tgroup" in the xml. Also I need...
4
by: Ken Kast | last post by:
Here's my situation. I have a statically positioned table that has an image in a cell. I also have some layers, defined by absolute-positioned DIVs for some animation. Everything works until I...
14
by: Zenobia | last post by:
Hello folks, Is it possible to position an item within a <td> element? For instance see below. The table has multiple rows, one for each database record. Each row has 3 hrefs associated with it...
3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
1
by: Dave Hammond | last post by:
I have an html element (a link) with an onclick handler which opens a popup window, and would like to position that window at the coordinates where the element appears on the page. I have...
7
by: Magnus Warker | last post by:
Hi, I want to traverse an (associative) array, starting from its current position, until a certain element is reached. Then, in certain cases, I want to be able to reset the current position of...
6
by: axlq | last post by:
I've spent most of the day struggling with what I thought would be a trivial problem. I have a hidden element that appears, outside of the normal flow, when the mouse hovers over an inline...
4
by: HoangTuanSu | last post by:
I have just got a javascript code from my friend. I've modified it for my purpose but a problem happens. First, here's my code html <body> <table align="center" width="60%" height="100%"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.