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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:56:21+00:00 2026-05-18T06:56:21+00:00

I have a web page with 16 textboxes arranged in a 4×4 grid. The

  • 0

I have a web page with 16 textboxes arranged in a 4×4 grid. The idea is that a user will type precisely one character into each textbox (specifically, a letter). You can see this page online at http://fuzzylogicinc.net/Boggle/EnterBoardClientSide.aspx

What I want to happen is the following:

  • When the page loads the upper left textbox is focused
  • Typing a letter in the textbox should enter that letter and then automatically set focus to the next textbox in the grid
  • If the user selects a textbox (either via the mouse or by Shift-Tabbing back to a previous textbox) the entry in the textbox should be selected so that they can just type the new letter to overwrite the old one.

I’ve got this working for the most part, but have one vexing problem – namely, if a user types the letters too fast, some textboxes are left empty, as if the code that whisks the user to the next textbox occurs before the browser has a chance to actually commit the letter to the textbox that had focus (if that makes any sense). If you visit my live demo and start typing at a decent rate, you’ll see that some textboxes are left blank.

My JavaScript, which can be seen it its entirety here, has the following code for selecting/focusing/moving to the next textbox:

$("input.BoggleGridCell")
    .focus(function () {
        $(this).select();
    })
    .keyup(function (event) {
        var code = (event.keyCode ? event.keyCode : event.which);

        if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122)) {
            var currentId = $(this).attr('id');

            var leftDigit = currentId.substring(1, 2);
            var rightDigit = currentId.substring(2, 3);
            if (leftDigit != 3 || rightDigit != 3) {
                if (rightDigit == 3) {
                    rightDigit = 0;
                    leftDigit++;
                }
                else {
                    rightDigit++;
                }

                var moveToId = 'c' + leftDigit + rightDigit;
                var newCell = document.getElementById(moveToId);
                if (newCell)
                    newCell.focus();
            }
            else {
                $("#solve").focus();
            }
        }
    });

Note that all my textboxes in the grid have a CSS class of BoggleGridCell. Each textbox in the grid has an id of the form cXY, where X is the row number and Y is the column number. I have a bit of code in the keyup event handler that examines this X and Y value of the current textbox’s id to determine the next textbox to focus.

What’s going on here? My intuition is that when typing at a sufficient pace that the keyup event for the first key press hasn’t completed by the time the keyup event for the subsequent key press is raised.

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-18T06:56:21+00:00Added an answer on May 18, 2026 at 6:56 am

    Figured a workaround… I ended up using jQuery’s keypress event plus JavaScript’s setTimeout function. Here’s the final code that appears to work as expected in IE 8, FF 3, and Google Chrome.

    $("input.BoggleGridCell")
        .focus(function () {
            $(this).select();
        })
        .keypress(function (event) {
            var code = (event.keyCode ? event.keyCode : event.which);
    
            if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122)) {
                var currentId = $(this).attr('id');
    
                var leftDigit = currentId.substring(1, 2);
                var rightDigit = currentId.substring(2, 3);
                if (leftDigit != 3 || rightDigit != 3) {
                    if (rightDigit == 3) {
                        rightDigit = 0;
                        leftDigit++;
                    }
                    else {
                        rightDigit++;
                    }
    
                    setTimeout(function () {
                        var moveToId = 'c' + leftDigit + rightDigit;
                        var newCell = document.getElementById(moveToId);
                        if (newCell)
                            newCell.focus();
                    }, 1);
                }
                else {
                    setTimeout('$("#solve").focus();', 1);
                }
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two jQuery autocomplete textboxes on a mvc web page. One that returns
I have a ASP.NET web page that contains many textboxes. Each textbox has a
I have a web page that includes a bunch of images. Sometimes the image
I have a web page with DIV s with a mouseover handler that is
I have a web page that displays a long line graph inside a div
I have a web page that is being displaying in a winform app using
I have a web page with 3 forms on it. Not nested, just one
I have a web page where it will input an excel/CSV file from the
I have a dynamic web page that after clicking a link, I insert a
I have a textbox on my web page that is used to specify a

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.