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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:25:13+00:00 2026-05-23T15:25:13+00:00

I needed to add an onclick event in a loop, so I searched and

  • 0

I needed to add an onclick event in a loop, so I searched and came across this: Setting onclick to use current value of variable in loop
The problem with it, however, is that it always returns a mouse event. I did pretty much the exact same thing except with my own function, but it just returns a mouse event. I have no clue why and it doesn’t make any sense to me. Here’s the code:

var a=m.getElementsByTagName('topic');
for(var b=0,c=a.length;b<c;b++) a[b].onclick=function(a) {
    return function(a) {
        goToMB(a);
        };
    }(a[b].getAttribute('topicid'));
  • 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-23T15:25:14+00:00Added an answer on May 23, 2026 at 3:25 pm

    Try this:

    var a = m.getElementsByTagName('topic');
    for(var b = 0, c = a.length; b < c; b++) {
        a[b].onclick = function(a) {
            return function() { goToMB(a); }
        }(a[b].getAttribute('topicid'));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attemping to use NetUseAdd to add a share that is needed by
I'm writing an add-in for ReSharper 4. For this, I needed to reference several
I want to add a button, with an onclick event, to the page. It
I'm starting to use Bootstrap from Twitter and needed to add an HTML Select
Scenario: I needed to add HttpUtility to my project, and I started by adding
I just downloaded Eclipse several hours ago, and needed to add Java3D to the
I'm using an HTML sanitizing whitelist code found here: http://refactormycode.com/codes/333-sanitize-html I needed to add
How can I add a param to the removeSound function in this JavaScript code?
I have forked an SVN project using Git because I needed to add features
I have a grid with link button and on RowDatabound: lbutton.Attributes.Add(onclick, javascript:window.showModalDialog('Showsome.aspx?ID= + lbutton.CommandArgument

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.