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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:02:14+00:00 2026-05-15T09:02:14+00:00

I made a script (using mootools library) that is supposed to overlay an image

  • 0

I made a script (using mootools library) that is supposed to overlay an image with a table grid and when each grid cell is clicked/dragged over its background color changes ‘highlighting’ the cell.

Current code creates a table and positions it over the element (el, image in this case). Table was used since I am planning to add rectangle select tool later on, and it seemed easiest way to do it.

<html>
<head>
    <title></title>
    <script type="text/javascript" src="mootools.js"></script>
    <script type="text/javascript">
     var SetGrid = function(el, sz, nr, nc){

            //get number of rows/columns according to the 'grid' size
            numcols = el.getSize().x/sz;
            numrows  = el.getSize().y/sz;
            //create table element for injecting cols/rows
            var gridTable = new Element('table', {
                'id' : 'gridTable',
                'styles' : {
                    'width' : el.getSize().x,
                    'height' : el.getSize().y,
                    'top' : el.getCoordinates().top,
                    'left' : el.getCoordinates().left
                }
            });

            //inject rows/cols into gridTable
            for (row = 1; row<=numrows; row++){
                thisRow = new Element('tr', {
                    'id' : row,
                    'class' : 'gridRow'
                });
                for(col = 1; col<=numcols; col++){
                    thisCol = new Element('td', {
                        'id' : col,
                        'class' : 'gridCol0'
                    });

                    //each cell gets down/up over event... down starts dragging|up stops|over draws area if down was fired
                    thisCol.addEvents({
                        'mousedown' : function(){
                            dragFlag = true;
                            startRow = this.getParent().get('id');
                            startCol = this.get('id');
                        },
                        'mouseup' : function(){
                            dragFlag = false;
                        },
                        'mouseover' : function(){
                            if (dragFlag==true){
                                this.set('class', 'gridCol'+$$('#lvlSelect .on').get('value'));
                            }
                        },
                        'click' : function(){
                            //this.set('class', 'gridCol'+$$('#lvlSelect .on').get('id').substr(3, 1) );
                            str = $$('#lvlSelect .on').get('id');
                            alert(str.substr(2, 3)); 
                        }
                    });
                    thisCol.inject(thisRow, 'bottom');
                };
                thisRow.inject(gridTable, 'bottom');
            };
            gridTable.inject(el.getParent());
     }

     //sens level selector func
     var SetSensitivitySelector = function(el, sz, nr, nc){
        $$('#lvlSelect ul li').each(function(el){
            el.addEvents({
                'click' : function(){
                    $$('#lvlSelect ul li').set('class', '');
                    this.set('class', 'on');
                },
                'mouseover' : function(){
                    el.setStyle('cursor','pointer');
                },
                'mouseout' : function(){
                    el.setStyle('cursor',''); 
                }
            });
        });
     }

     //execute
     window.addEvent('load', function(){
        SetGrid($('imagetomap'), 32);
        SetSensitivitySelector();
     });


    </script>
    <style>
        #imagetomapdiv { float:left; display: block; }
        #gridTable { border:1px solid red; border-collapse:collapse; position:absolute; z-index:5; }
        #gridTable td { opacity:0.2; filter:alpha(opacity=20); }
        #gridTable .gridCol0 { border:1px solid gray; background-color: none;   }
        #gridTable .gridCol1 { border:1px solid gray; background-color: green;  }
        #gridTable .gridCol2 { border:1px solid gray; background-color: blue;   }
        #gridTable .gridCol3 { border:1px solid gray; background-color: yellow; }
        #gridTable .gridCol4 { border:1px solid gray; background-color: orange; }
        #gridTable .gridCol5 { border:1px solid gray; background-color: red;    }
        #lvlSelect ul {float: left; display:block; position:relative; margin-left: 20px; padding: 10px; }
        #lvlSelect ul li { width:40px; text-align:center; display:block; border:1px solid black; position:relative; padding: 10px; list-style:none; opacity:0.2; filter:alpha(opacity=20); }
        #lvlSelect ul li.on { opacity:1; filter:alpha(opacity=100); }
        #lvlSelect ul #li0  { background-color: none;   }
        #lvlSelect ul #li1  { background-color: green;  }
        #lvlSelect ul #li2  { background-color: blue;   }
        #lvlSelect ul #li3  { background-color: yellow; }
        #lvlSelect ul #li4  { background-color: orange; }
        #lvlSelect ul #li5  { background-color: red;    }
    </style>
</head>

<body>
    <div id="imagetomapdiv">
        <img id="imagetomap" src="1.png">

    </div>
    <div id="lvlSelect">
        <ul>
            <li value="0" id="li0">0</li>
            <li value="1" id="li1">1</li>
            <li value="2" id="li2">2</li>
            <li value="3" id="li3">3</li>
            <li value="4" id="li4">4</li>
            <li value="5" id="li5" class="on">5</li>
        </ul>
    </div>
</body>
</html>

There are two problems: while it works just fine in FF, IE and Chrome do not create the table if the page is refreshed. If you go back to directory root and click on the link to the file the grid table is displayed, if you hit ‘refresh’ button — the script runs but the table is not injected.

Secondly, although the table HTML is injected in IE, it does not display it. I tried adding nbsp’s to make sure its not ignored — to no avail.

Any suggestions on improving code or help with the issues is appreciated.

Thanks!

  • 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-15T09:02:15+00:00Added an answer on May 15, 2026 at 9:02 am

    Try adding a docType dec at the top of the page IE:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try using : NSError *error = nil; path=@"/Users/aryaxt/Desktop/test2.avi"; [data writeToFile:path… May 16, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer Here is what I could figure out: these new fields… May 16, 2026 at 3:21 pm
  • Editorial Team
    Editorial Team added an answer Your copying appears to be correct (the memcpy, at least).… May 16, 2026 at 3:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've made an image upload script using the move_uploaded_file function. This function seems to
I have made a chat script using php, mysql and jquery. It uses json
I have images to overlay on google maps by using checkboxes. I made this
I have a problem. I have made a script to convert a given HTML
I am batch converting some pictures with a quick and dirty bash script using
I made a website using the famous symfony framework. I wanted to add rich
I'm using an autosuggestion for addresses through Google Maps API that I want to
I have a simple python script that just takes in a filename, and spits
I have a PHP script that reads a file and outputs it to the
A few days ago I posted this question: switch statement and loops using jquery/javascript

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.