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

  • Home
  • SEARCH
  • 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 6791113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:48:24+00:00 2026-05-26T17:48:24+00:00

I’m trying to develop a plugin that shows website screenshot, when a user clicks

  • 0

I’m trying to develop a plugin that shows website screenshot, when a user clicks on the name of the comment’s author.
All works when there is just one comment, but when are more than one comment the script doesn’t work.
I think the problem is in the name of the variable called and posted for each comment.
But I don’t know how to dynamically change the name of the JS variable and how to dynamically call it.

This is the code for mouseover (in the header)

    <script type="text/javascript">
function MOver(picimage)
{
Picture_Over = eval(picimage +"On.src")
document[picimage].src = Picture_Over
}
function MOut(picimage)
{
Picture_Out = eval(picimage +"Off.src")
document[picimage].src = Picture_Out
}
-->
</script>

Then this is the code to show the mouseover:

    <script type="text/javascript"><!--

var Img2On = new Image();
Img2On.src = "<?php echo $urlnohttp;?>";
var Img2Off = new Image();
Img2Off.src = "<?php bloginfo('url');?>/wp-content/plugins/[...]/control_play.png";

</script>
<a href="<?php echo $commenturl ?>" onMouseOver="MOver('Img2')" onMouseOut = "MOut('Img2')" ><?php echo $author ?> <img src="<?php bloginfo('url');?>/wp-content/plugins/[...]/control_play.png" border="0" name="Img2"></img></a> 

I think the problem is in the “Img2” name that isn’t unique.

  • 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-05-26T17:48:24+00:00Added an answer on May 26, 2026 at 5:48 pm

    I am moving most of my comment over to this answer:

    To dynamically call a variable, change the function to look like this:

    function MouseChange( img , imageSrc ) // img will be the tag name, and imageSrc will be the URL of the image
    {
        document[img].src = imageSrc;
    }
    

    To call this you will do this:

    <?php $blogPostID = ???;// I don't know how to get blog post ID of the top of my head ?>
    <script type="text/javascript"><!--
        var Img<?= $blogPostID ?>On = new Image();
        Img<?= $blogPostID ?>On.src = "<?php echo $urlnohttp;?>";
        var Img<?= $blogPostID ?>Off = new Image();
        Img<?= $blogPostID ?>Off.src = "<?php bloginfo('url');?>/wp-content/plugins/[...]/control_play.png";
    // this closes the HTML comment: --></script>
    
    <a href="<?php echo $commenturl ?>" onMouseOver="MouseChange( 'Img<?= $blogPostID ?>' , Img<?= $blogPostID ?>On.src )" onMouseOut = "MouseChange( 'Img<?= $blogPostID ?>' , Img<?= $blogPostID ?>Off.src )" ><?php echo $author ?>
        <img src="<?php bloginfo('url');?>/wp-content/plugins/[...]/control_play.png" border="0" name="Img<?= $blogPostID ?>" />
    </a>
    

    So what I did was replace all the numbers with the blog post ID, then you can be [relatively] sure it is unique, as long as no other parts of the page makes things called “Img#”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but

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.