Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7810135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:39:53+00:00 2026-06-02T03:39:53+00:00

I have a div that I want to appear directly below a table cell

  • 0

I have a div that I want to appear directly below a table cell when the table cell is clicked. Here is a sample of my code so far…

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
    function toggleDownloadSelectionDialog(divToggle,divId,event){
        pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById(divToggle).offsetLeft;
        pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById(divToggle).offsetTop;

        alert(pos_y+"  "+pos_x+" "+divId);

        document.getElementById(divId).style.top = pos_y;
        document.getElementById(divId).style.left = pos_x;
        document.getElementById(divId).style.display = 'block';

    }
</script>
</head>

<body>
<div class="div_downloadDialog" id="div_hidden1" style="display: none; top: 0; left: 0; position: absolute;">This div is hidden</div>

<table class="Oligo_Diversity">

<tr>
<td>blah</td><td>blah</td><td>blah</td>
</tr>

<tr>
<td><div id="div_toggle1" onclick="toggleDownloadSelectionDialog('div_toggle1','div_hidden1',event);">click here for download dialog</div></td>
<td>blah</td>
<td>blah</td>
</tr>

</table>

</body>
</html>

I would like the hidden download div to appear directly below the table cell it is clicked on. My javascript seems to get the position but I’m having trouble passing this information to the div. Removing the DOCTYPE will make this work but for the project I’m working on I need a doctype. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:39:56+00:00Added an answer on June 2, 2026 at 3:39 am

    Set position: absolute for the DIV as sv_in said.

    This line also may cause troubles in IE:

    pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById(divToggle).offsetLeft;
    

    If you’ll run this in IE, ternary operator finds the condition true and returns true after ?.

    Switch the line to:

    pos_x = (event.offsetX)?event.offsetX:event.pageX-document.getElementById(divToggle).offsetLeft;
    

    And the same on next line for pos_y.

    When using <!DOCTYPE html> also units have to be used in style definitions:

    document.getElementById(divId).style.left = pos_x+'px';
    document.getElementById(divId).style.top = pos_y+'px';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the second table cell I have a div inside of it that I
I have a div that I want to appear based on user input (works),
I have a div that I want to appear on top of some UI
I have a table div that contains two cells. I want the cells to
I have a DIV that I want to touch the bottom of the screen
I have a div that I want to toggle between displaying or not when
I have a div that I want when user click on a button slideUp
I have a menu div that I want to slide down so it's always
I have a floating div that gets displayed, and I want it to be
I have a square DIV(300px x 300px) that I want to flip every 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.