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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:09:16+00:00 2026-05-29T04:09:16+00:00

I am very new with java script and jQuery and managed to create a

  • 0

I am very new with java script and jQuery and managed to create a editable table that will do some calculations I needed to do. Problem is, when I use tab, I would like it to move the cursor to next cell.

This is first time posting here as well so please bear with me if I sound ridiculous!

Here is how my html part of the code looks.

<div id = "showTable" contentEditable="true" tabindex="0">
<table id="tbl" width = "850px" border="1">
    <tbody>
    <th>Date Worked</th>
    <th>Start</th>
    <th>Meal break</th>
    <th>End</th>
    <th>Hourly Wage</th>
    <th>Gross Earnings</th>
    <th>Pay Date</th>
    </tbody>

 </table>
</div>

After, in the javascript, I have function (which I found online) that will create dynamic table.

function createDynamicTable(tbody, rows, cols) 
{
    if (tbody == null || tbody.length < 1) return;
    for (var r = 0; r < rows; r++) 
    {
        var trow = $("<tr>");
        for (var c = 0; c < cols; c++) 
        {
            if(c == 0)
            {
                var dateWorked = "mm/dd/yyyy" ;
                $("<td>")
                        .addClass("tableCell")
                        .text(dateWorked)
                        .data("col", c)
                        .appendTo(trow);
                col[counter] = dateWorked;
                counter++;
                masterCounter++;
            }
            else if (c == 1)
            {
                var startTime = "h:mm AM/PM";
                $("<td>")
                        .addClass("tableCell")
                        .text(startTime)
                        .data("col", c)
                        .appendTo(trow);

                col[counter] = startTime;
                counter++;
                masterCounter++;
            }
            else if (c == 2)
            {
                var mealBreakMin = "time in minutes";
                $("<td>")
                        .addClass("tableCell")
                        .text(mealBreakMin)
                        .data("col", c)
                        .appendTo(trow);

                col[counter] = mealBreakMin;
                counter++;
                masterCounter++;
            }
            else if (c == 3)
            {
                var endTime = "h:mm AM/PM";
                $("<td>")
                        .addClass("tableCell")
                        .text(endTime)
                        .data("col", c)
                        .appendTo(trow);

                col[counter] = endTime;
                counter++;
                masterCounter++;
            }
            else if (c == 4)
            {
                var hourlyWage = "$-.--";
                $("<td>")
                        .addClass("tableCell")
                        .text(hourlyWage)
                        .data("col", c)
                        .appendTo(trow);

                col[counter] = hourlyWage;
                counter++;
                masterCounter++;
            }

            if(r == 6)
            {
                if (c == 5)
                {
                    var grossPay = "$-.--";
                    $("<td>")
                    .addClass("tableCell")
                    .text(grossPay)
                    .data("col", c)
                    .appendTo(trow);

                    col[counter] = hourlyWage;
                    counter++;
                    masterCounter++;
                }

                else if (c == 6)
                {
                    var payDate = "mm/dd/yyyy";
                    $("<td>")
                    .addClass("tableCell")
                    .text(payDate)
                    .data("col", c)
                    .appendTo(trow);

                    col[counter] = hourlyWage;
                    counter++;
                    masterCounter++;
                }
            }

        }
        trow.appendTo(tbody);
    }
    counter = 0;
}

Now, on jQuery part, I tried something like

$(".tableCell").live('click', function(e) {
    document.execCommand('selectAll', false, null);
});

Even though my goal is to tab to next cell, I first tried the following.

I thught above code will highlight one part of the cell only. However, it will highlight entire cell. I did look around the web but could not find exact answer where how their table was made was similar to mine.

It would be awesome if anyone can help me with this.

  • 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-29T04:09:16+00:00Added an answer on May 29, 2026 at 4:09 am

    To illustrate what I had suggested, I put together a jsFiddle to see if this matches what you are after:

    http://jsfiddle.net/u4pAg/2/

    Just a few <tr> with 7 <td> to match your <th> in your example. Each of the <td> contains an <input type="text" /> tag with the default value based on what was in your createDynamicTable() function.

    I also added a stitch of jQuery… first, I am looping through all the inputs and store their ddefault value using jQuery’s .data() method (http://api.jquery.com/data/) for later use. I remove the default value on focus (but only if it is still the default value). If it is not the default value, it keeps that content there and just selects the content for easy replacing/updating (can be removed out if you don’t like the auto selecting). On blur, I check if the input is left blank and if so, I add back the previously stored default value. I through in some CSS in there as well for some visual interest.

    EDIT——

    If in your createDynamicTable() function, you update the points where you are setting the .text() for your <td> and instead set the .html() to include an input tag instead of just text, it turn out something like this (I just commented out the vars that it was looking for that were not defined, per my comment to your post):

    http://jsfiddle.net/u4pAg/4/

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

Sidebar

Related Questions

I am really new to Java and I read that synchronized is very expensive
I am very new to Javascript and jQuery. I managed to make a dialog
I'm very new to both the Mvc framework as well as JavaScript and JQuery.
I am very new at jQuery ... I've used Javascript many times and am
I noticed that JavaScript's new Date() function is very smart in accepting dates in
I am very new to Java, I want to add a PNG image to
I'm very new to Java but I've been developing a habit to use final
I am very new to processing.org and Java. I am trying to store objects
I'm very new to Python (I'm coming from a JAVA background) and I'm wondering
I'm soon going to check in the very first commit of a new Java

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.