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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:34:11+00:00 2026-06-17T11:34:11+00:00

I’d like to create a numbered grid.The user puts in the number and the

  • 0

I’d like to create a numbered grid.The user puts in the number and the grid is generated. I’d like to do it in CSS, HTML or Jquery Mobile. This is for an ipad project. I’m not sure how to approach the problem. I would like the following result:
numbered grid that is auto generated

As it stands now, I have a div that repeats a grid image across the page. I have to regenerate an image for each background. i.e.: user wants a 40X60 feet area, I will have to generate a 40X60 image. (100px=5 feet on the grid) I’d much rather have the user input two numbers and have the grid and numbers auto generated.

<div style="background-image:url(/images/linegrid100.png);
width:980px;height:700px;
border:1px solid black;padding:10px;">

I’ve looked at a serious number of grid generators. I’ve thought about using a table rather than an image. Would that be better? How do I approach the math for the number generation? Seems like this should all be pretty straight forward, but I can’t find much information. (Googled for a couple of days now) These kinds of grids are done all of the time in graphics programs and CAD programs.

Any help would be appreciated.

TIA -Rachel


OK. Here is the result of your code. It is running 🙂 but not as expected. I’ve been working with the code all day. It is making more sense now, but I’m still lost with the loops and math. Any ideas? So nice to have help and this is fun. Thanks again -R

The code that seems to impact things is :

w = parseInt($square.css('width'), 10) + 2; //the width of each square + 2 pixels for the borders;

If I leave it just as you have it:
enter image description here

If I change the 10 to 100:

enter image description here

  • 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-17T11:34:12+00:00Added an answer on June 17, 2026 at 11:34 am

    Let’s assume you have the following form where users enter the two numbers:

    <form>
        <input type="text" id="x">
        <input type="text" id="y">
    </form>
    

    Then you can use jQuery to generate your grid as follows:

    var x = parseInt($('#x').val(), 10),
        y = parseInt($('#y').val(), 10);
    
    grid(x, y);
    
    function grid(x, y) {
       var i = -1,
           j = -1,
           step = 5, //assuming that each grid unit = 5
           $grid = $('<div>', {'id':'grid'}),
           $square = $('<div>', {'class':'square'}),
           $label,
           w = parseInt($square.css('width'), 10) + 2; //the width of each square + 2 pixels for the borders;
    
      $grid.width(w * x);
    
      while(++i < x) {
           while(++j < y) {
            if(j === 0) {
            $label = $('<span>', {'class':'label'});
            $label.css('top', j * w).css('left', i * w).html(i * step);
            }
            if(i === 0 && j > 0) {
                $label = $('<span>', {'class':'label'});
            $label.css('top', j * w).css('left', i * w).html(j * step);
                }
                $grid.append($square.clone(), $label);
           }
           j = -1;
      }
      $('body').append($grid);
    }
    

    CSS:

    #grid { overflow: hidden; border-left: 1px solid #000; border-top: 1px solid #000; position: relative; }
    div.square { width: 50px; height: 50px; float: left; border-bottom: 1px dotted #000; border-right: 1px dotted #000; }
    span.label { position: absolute; background: #fff; font-weight: bold; z-index: 10; }
    

    Let’s say here’s our overlay (dialog box):

    <div>
        <input type="text" id="x">
        <input type="text" id="y">
        <button id="build-grid" type="button">Build grid</button>
    </div>
    

    Then, you attach an onclick event to the build-grid button. So, when the button is clicked, we read the x and y values and build the grid.

    $('#build-grid').on('click', function(e){
       e.preventDefault();
       var x = parseInt($('#x').val(), 10), //get our values from the input fields
           y = parseInt($('#y').val(), 10);
    
       grid(x, y); // build the grid
    });
    
    • 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
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
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,

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.