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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:24:17+00:00 2026-05-23T16:24:17+00:00

I create a table that contain rows and on last ‘td’ on each row

  • 0

I create a table that contain rows and on last ‘td’ on each row there is an ‘img’ to insert new row onClick="addRow()". I want this new row to insert below clicked row. Clearly, if I have row X and row Y and I click on the ‘img’ on X row then I will get the new row below X and above Y.
I used this code for insertion:

function addRow()
{

    var newRow = document.all("tblGrid").insertRow(-1);

    var oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='text' name='t1'>";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='text' name='t2'>";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='text' name='t3'>";

    oCell = newRow.insertCell();
    oCell.innerHTML = "<input type='text' name='t4'>";   
}

and this the table:

<table id="tblGrid" cellspacing="0">
    <tr>

      <th>Instraction</th>
      <th>Result</th>
      <th>Time</th>
      <th>Date</th>
      <th>Add</th>
    </tr>
    <?php do { ?>
      <tr>
        <td><?php echo $row_instRecordset['instName']; ?></td>
        <td><?php echo $row_instRecordset['instValue']; ?></td>
        <td><?php echo $row_instRecordset['instTime']; ?></td>
        <td><?php echo $row_instRecordset['instDate']; ?></td>
        <td><img onClick="addRow()" width="20px" height="20px" src="images/add_32.png"/></td>
      </tr>
      <?php } while ($row_instRecordset = mysql_fetch_assoc($instRecordset)); ?>
  </table>

How I can do this with jQuery? I need also 3rd cell to be current time and 4th cells to be current date auto generated?
Any help will be appreciated…

  • 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-23T16:24:17+00:00Added an answer on May 23, 2026 at 4:24 pm

    Remove the onClick attribute and add the following code to your page:

    (function() {
      $('td img').live('click', function() {
         d = new Date();
         date = d.getMonth() + '/' + d.getDay() + '/' + d.getFullYear();
         time = d.getHours() + ':' + d.getMinutes();
         $(this).closest('tr').after(
           $('<tr>').append(
             $('<td>').html($('<input>').attr({'type': 'input', 'name': 't1'})))
             .append($('<td>').html($('<input>').attr({'type': 'input', 'name': 't2'})))
             .append($('<td>').html($('<input>').attr({'type': 'input', 'name': 't3'}).val(date)))
             .append($('<td>').html($('<input>').attr({'type': 'input', 'name': 't4'}).val(time))));
    
         );
      }
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains multiple rows. Each row contains 5 columns (or
Hi there I have an SQL table that looks like this: CREATE TABLE IF
I have a table that contains computer login and logoff events. Each row is
in web application, i have a gridview in that each row contain 3 textboxes
I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start:
Is it possible for me to create and use a database table that contains
I have a table that contains id, created, user_id. I'm wondering if there is
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
I'm creating a table that looks something like this. CREATE TABLE packages ( productCode
I'd like to create a table that looks like this: lolvalue---------|lol date|some other column

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.