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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:42:06+00:00 2026-05-30T05:42:06+00:00

I’m confused why this is ot working: var blocks = document.getElementsByTagName(td); var i =

  • 0

I’m confused why this is ot working:

var blocks = document.getElementsByTagName("td");
        var i = 0;
        for(i=0;i<blocks.length;i++){
            var id = String(blocks[i].id);
            var col_pos_y = document.getElementById(id).style.top;
            alert(col_pos_y);

        }

Am I missing something, because firefox seems to just alert out a blank alert message? Anyone got an idea why this isn’t working?

This is the html/php code for the generation of the td’s

<table cellspacing="0" cellpadding="0" style="position: absolute; top: 80%; z-index:5;" border="0">
<?php
$blocks = array();
for($k=1;$k<=3;$k++){   
    $row_number = "row_".$k;
?>
    <tr id="<?php echo $row_number; ?>">
<?
    for($i=0;$i<=100;$i++){
        if($k==1){
            $rand_number = rand(0, 100);
        }
        else if($k==2){
            $rand_number = rand(30, 100);
        }
        else if($k==3){
            $rand_number = rand(50, 100);
        }
        if($rand_number<50){
            for($l=0;$l<=count($blocks);$l++){
                $row_counter = $k-1;
                if($blocks[$l]=="row_".$row_counter."_col_".$i."_type_grass"){
                    $block_exists="true";
                    break;
                }
                else{
                    $block_exists="false";
                }
            }
            if($block_exists=="true"){
                array_push($blocks, $row_number."_col_".$i."_type_grass");

                $background_position = generate_dirt_block();
                ?>
                    <td id="<?php echo $row_number; ?>_col_<?php echo $i ?>_type_grass" style="font-size: 10px; cursor: pointer; background-image:url('img/terrain.png'); background-repeat: no-repeat; background-position: <?php echo $background_position ?>; min-width: 32px; height: 32px;">

                    </td>
                <?php
            }
            else{
                array_push($blocks, $row_number."_col_".$i."_type_blank");
                ?>
                     <td id="<?php echo $row_number; ?>_col_<?php echo $i ?>_type_blank" style="font-size: 10px; min-width: 32px; height: 32px;">

                     </td>
                <?php
            }
        }
        else if($rand_number>=50  && $rand_number<=100){
            array_push($blocks, $row_number."_col_".$i."_type_grass");
            for($l=0;$l<=count($blocks);$l++){
                $row_counter = $k-1;
                if($blocks[$l]=="row_".$row_counter."_col_".$i."_type_grass"){
                    $block_exists="true";
                    break;
                }
                else{
                    $block_exists="false";
                }
            }
            if($block_exists=="true"){
                $background_position = generate_dirt_block();
                ?>
                    <td id="<?php echo $row_number ?>_col_<?php echo $i ?>_type_grass" style="font-size: 10px; cursor: pointer; background-image:url('img/terrain.png'); background-repeat: no-repeat; background-position: <?php echo $background_position ?>; min-width: 32px; height: 32px;">

                    </td>
                <?php
            }
            else{
                ?>
                    <td id="<?php echo $row_number; ?>_col_<?php echo $i ?>_type_grass" style="font-size: 10px; cursor: pointer; background-image:url('img/terrain.png'); background-repeat: no-repeat; background-position: 0px -32px; min-width: 32px; height: 32px;">
                        <div style="width: 100%; position: relative; top: 0px;">
                            <div style="background-image:url('img/terrain.png'); background-repeat: no-repeat; background-position: -384px 0px; width: 32px; height: 10px; position: absolute; top: -17px;">

                            </div>
                        </div>
                    </td>
                <?php
            }
        }
    }
?>
    </tr>
<?php
}
?>
</table>
  • 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-30T05:42:08+00:00Added an answer on May 30, 2026 at 5:42 am

    If getElementById() wasn’t working, then trying to access .style.top on the return value would error and the alert would never be reached.

    The .style.top property of the element is simply blank (indicating that it has not been set with either JavaScript or the style attribute).

    Use getComputedStyle if you want to access the property as applied via the cascade.

    Use offsetTop if you want to work out its position as set via normal flow).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And

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.