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 8787107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:48:11+00:00 2026-06-13T21:48:11+00:00

I have a script that works to switch between two popups that are triggered

  • 0

I have a script that works to switch between two popups that are triggered by an onmouseover event. One feature of this is that the popup persists until the next onmouseover event. I want to have many of these and so the popup to be hidden can not be ‘hard coded’ as in my script. Is there a way to store in a variable the id of the popup that needs to be undisplayed the next time the popup function is called?

<!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 popup(show,hide){
    show.style.display="block"
    hide.style.display="none"
    }
</script>
<style type="text/css">
.pop {
    position: absolute;
    display: none;
    top: 50px;
    left: 200px;
    width: 300px;
}
</style>
</head>
<body>

<table><tr>
<td onmouseover="popup(pop1,pop2)">Show popup 1</td>
<td onmouseover="popup(pop2,pop1)">Show popup 2</td>
</tr></table>

<div class="pop" id="pop1">This is popup 1</div>
<div class="pop" id="pop2">Popup 2 is here</div>

</body>
</html>  

or go to http://www.salemharvest.org/Utilities/TestingPHP/testingpopupdivs5.php

  • 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-13T21:48:13+00:00Added an answer on June 13, 2026 at 9:48 pm

    One way to generalize it is to use element index to show the associated popup. This will require that the popup elements (pop class elements) is contained by an element, in order to make both the popper and the popup element indexes mapped equally like two arrays of same length.

    When showing a popup, the popup element is saved in a variable which will be used later when the mouse is on a different popper element.

    <!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">
    addEventListener("DOMContentLoaded", function() {
      var lastPopup = null;
      function showit(ev) {
        var popups = document.getElementById("popups").children;
        eleToShow = popups[ev.target.cellIndex];
        if (lastPopup && (lastPopup !== eleToShow)) lastPopup.style.display = "none";
        eleToShow.style.display = "block";
        lastPopup = eleToShow;
      }
      var poppers = document.getElementById("poppers").cells, i;
      for (i = 0; i < poppers.length; i++) {
        poppers[i].addEventListener("mouseover", showit, false);
      }
    }, false);
    </script>
    <style type="text/css">
    .pop {
        position: absolute;
        display: none;
        top: 50px;
        left: 200px;
        width: 300px;
    }
    </style>
    </head>
    <body>
    
    <table><tr id="poppers">
    <td>Show popup 1</td>
    <td>Show popup 2</td>
    </tr></table>
    
    <div id="popups">
    <div class="pop">This is popup 1</div>
    <div class="pop">Popup 2 is here</div>
    </div>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script that works, but I need to change the format of
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
We have a ubuntu test server that this simple script works fine on where
I have a script that works great. It is quite complex and does numerous
With help from you guys I now have a script that works like a
I have the following script that works well in Firefox and Chrome (not sure
I have a script on here that works fine in FF14 and Chrome20. A
I have a simple images resizing script that works great for JPEGs, but not
I have a nodejs script that uses phantomjs-node to scrape a webpage. It works
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>

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.