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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:58:22+00:00 2026-05-19T00:58:22+00:00

hi i got the problem the script.js gives me <div id=gracze> <div id=10 class=char

  • 0

hi i got the problem the script.js gives me

<div id="gracze">
  <div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div>
  <div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div>
</div>

instead

<div id="gracze">
  <div id="4" class="char" ... ></div>
  <div id="10" class="char" style="z-index: 19; top: 592px; left: 608px; "></div>
  <div id="14" class="char" style="z-index: 25; top: 784px; left: 608px; "></div>
</div>

get_players.php

4/62/6
10/19/19
14/19/25

script.js

function get_players()
{
    $.ajax({   
    type:   "POST",
    url:    "get_players.php",   
    dataType: "html",  
    success:  function(data) {
        var str = data;
                var chars = str.split("<br />");
                var lol = chars.length;
                for(var i = lol; i--; ) {
                    chars[i] = chars[i].split('/');
                    var o = document.getElementById(chars[i][0]);
                    var aimt = i;
                    if (!o) {
                        if (aimt!=chars.length-1 && aimt != 0) {
                            $('#gracze').html('<div id="'+chars[aimt][0]+'" class="char"></div>'+$('#gracze').html());
                            $('#'+chars[aimt][0]).css("top", chars[aimt][2]*32-16+"px");
                            $('#'+chars[aimt][0]).css("left", chars[aimt][1]*32+"px");
                            $('#'+chars[aimt][0]).css("z-index", chars[aimt][1]*32);
                        }
                    } else {
                        $('#'+chars[aimt][0]).animate({
                            "top": chars[aimt][2]*32-16+"px", "left": chars[aimt][1]*32+"px"
                        }, { duration: 275});
                        //$('#'+chars[aimt][0]).css("top", chars[aimt][1]*32-16+"px");
                        //$('#'+chars[aimt][0]).css("left", chars[aimt][2]*32+"px");
                        $('#'+chars[aimt][0]).css("z-index", chars[aimt][2]);
                    }
                }
        }});
    setTimeout("get_players();", 1000);
}

I think it’s because of for(var i = lol; i--; ) {

  • 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-19T00:58:23+00:00Added an answer on May 19, 2026 at 12:58 am

    Change the loop to this:

    for(var i = lol - 1; i >= 0 ;i-- )
    

    Javascript array indexes start with 0 and end with the size of the array -1 (so if an array has 5 elements, the first one will have index of 0 and the last one of 4).

    Your original loop starts with the size of the array, immediately decrementing it (so the last element is accessed). The loop continues until the variable decrements to 0, at which point the loop is existed, without the first element being used.

    See this page about looping over arrays in javascript.


    Additionally, this condition if (aimt!=chars.length-1 && aimt != 0) specifically excludes the last element. Remove the && aimt != 0.

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

Sidebar

Related Questions

I've got a little problem with Zend Framework Zend_Pdf class. Multibyte characters are stripped
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
I got a problem like this (this is html/css menu): Eshop | Another eshop
I've got a problem here with an MSI deployment that I'm working on (using
I've got a problem with inheritance and generics. This is the code that illustrates
I've got a problem where I have a .co.uk domain of which I am
I've got a problem similar to,but subtly different from, that described here (Loading assemblies
On Vista, I got a problem with the application crash handler. Basically, if something
I've got this weird problem - I'm calling ChangeServiceConfig on a newly installed service
I have got the following problem since the server has safe mode turned on,

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.