Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Position div next to element

Reply
Thread Tools

Position div next to element

 
 
johkar
Guest
Posts: n/a
 
      04-13-2006
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)">

 
Reply With Quote
 
 
 
 
petermichaux@gmail.com
Guest
Posts: n/a
 
      04-13-2006

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

 
Reply With Quote
 
 
 
 
johkar
Guest
Posts: n/a
 
      04-14-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div class="position"> and <div class" section"> Luigi Donatello Asero HTML 31 05-07-2006 02:52 AM
Re: <div class="position"> and <div class" section"> Luigi Donatello Asero HTML 0 05-06-2006 01:55 PM
How do you Pass Mouse Events through DIV element to the DIV element beneath it? CRPietschmann Javascript 1 04-28-2006 07:28 AM
CurrentElement->next = CurrentElement->next->next (UNDEFINED?) Deniz Bahar C Programming 2 03-09-2005 12:45 AM
CSS: How to position a DIV below a floating DIV? Tamlyn Rhodes HTML 3 02-26-2004 10:33 PM



Advertisments