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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:49:01+00:00 2026-06-11T01:49:01+00:00

As explained here http://www.mennovanslooten.nl/blog/post/62/ code below outputs result just for 5×5 forgetting about anything

  • 0

As explained here http://www.mennovanslooten.nl/blog/post/62/ code below outputs result just for “5×5” forgetting about anything before that.

for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {

    var cords = x+"x"+y;
    var el = document.getElementById(cords);
    el.addEventListener("click", function (e) { B_modeWindow('1', cords); });

}
}

As far I have the informations (blog link provided above) can’t figure out how to alter showed code to fix it.

How to walk around this code with JavaScript closure in my for-loop?

edit: I dont get it. varibles are defined in good way. Test:

for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {

    var cords = x+"x"+y;
    alert(cords);

}
}
  • 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-11T01:49:03+00:00Added an answer on June 11, 2026 at 1:49 am

    Call the function with anything you need to be closed as an argument. In this case, that’s cords.

    for (x = 1; x <= 5; x++) {
        for (y = 1; y <= 5; y++) {
            var cords = x + "x" + y;
            var el = document.getElementById(cords);
    
            (function(cords) {
                el.addEventListener("click", function (e) { B_modeWindow('1', cords); });
            })(cords);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry just found this code here - http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html and the mutex was explained with
Trying to implement the excellent jQuery bidirectional infite scroll as explained here: http://www.bennadel.com/blog/1803-Creating-A-Bidirectional-Infinite-Scroll-Page-With-jQuery-And-ColdFusion.htm For
I used sliding doors technique, explained here: http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html With only one exception, that I
The complete code can be found here: http://www.webdeveloper.com/forum/showthread.php?t=224180#6 This emulates jquery like functionality. The
I want to load properties from property file as explained here http://www.soapui.org/Scripting-Properties/working-with-properties.html . I
Paging is explained here, slide #6 : http://www.cs.ucc.ie/~grigoras/CS2506/Lecture_6.pdf in my lecture notes, but I
I am trying to follow what is being explained here: http://www.djangobook.com/en/2.0/chapter03/ (the confusing example
I'm trying to add a Search-ActionView to my application (as explained here http://developer.android.com/guide/topics/search/search-dialog.html#UsingSearchWidget ).
Normally I would post the code of just the menu but the menu on
The question originated from here: http://www.java.net/forum/topic/glassfish/glassfish/configuring-glassfish-logging-format - without an answer. The default GlassFish 3

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.