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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:20:28+00:00 2026-06-01T15:20:28+00:00

I am starting to write some javascript for my site to create a better

  • 0

I am starting to write some javascript for my site to create a better user experience but i am getting a little confused on what exactly is happening, and maybe it is clearly evident to someone else what I am doing wrong or missing. I have two javascript functions that work perfect after the first time of use and if you use it slowly (sometimes it skips the next item and selects nothing if you press two keys too fast). I feel that I am missing some sort of $(document).ready(function() {}); implementation to make sure that each process has finished before it moves on. I have two textboxes that the user puts in two numbers then it moves on to the next tab element (the next textbox). The textboxes are also in an asp.net update panel if that has any impact.

    function selectall(item) {
            $(item).focus().select();
    };

    function selectNext(textBox) {
        if ($(textBox).val().length == 2) {
            $(textBox).next().focus().select();
        }
    };

        <asp:TextBox ID="Text1" runat="server" Width="30px" AutoPostBack="True"  onkeyup="selectNext(this);" onclick="selectall(this);"
    Height="20px"></asp:TextBox>:
                <asp:TextBox ID="Text2" runat="server" Width="30px" AutoPostBack="True" onkeyup="selectNext(this);" onclick="selectall(this);"
    Height="20px"></asp:TextBox>
                 <asp:DropDownList ID="Text2" runat="server"
  • 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-01T15:20:29+00:00Added an answer on June 1, 2026 at 3:20 pm

    Why do you need to contain the textboxes in an UpdatePanel?

    It’s possible that the AutoPostback you have set on your textboxes is causing issues with your jQuery since a page post back will occur whenever the TextBox control loses focus.

    I would take your textboxes out of your UpdatePanel, remove the AutoPostback and place your JavaScript in a document.ready.

    Edit

    Code snippet:

    $(document).ready(function() {
        $("#fname").keyup(function() {
            selectNext($(this));
        });
    
        $("#fname").focus(function() {
            $(this).select();
        });
    
        $("#lname").keyup(function() {
            selectNext($(this));
        });
    
        $("#lname").click(function() {
            $(this).select();
        });
    });
    
    function selectNext(textBox) {
        if (textBox.val().length == 2) {
            setTimeout(function() {
                textBox.next().focus().select();
            }, 5);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting to write some unit test for my javascript code using qunit and
I have been starting to write some reasonably large and or confusing MySQL queries
I am starting to write some code for A/B testing in a Grails web
I am just starting to write ruby rails. I wrote a controller but is
So, I'm starting to write some logic for a simple program (toy game on
We are starting to create an application using JavaScript and HTML5 which will use
I am just starting to write some documents with Sweave/R and I like the
I am attempting to write some Tests for a small project of mine but
We are starting to write more and more code for an ASP.Net web application
I'm starting to write more and more web applications for work. Many of these

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.