HTML5

Simple Example of Editable Table in HTML5

In this tutorial, I will let you know, creating editable table in html5, bootstrap and jquery. It’s the magic of HTML5. You can provide an inline editable option on any HTML element using an editable attribute >.

It’s very easy and simple to use with HTML elements. Here, we are creating html table editable on client side. You can also make editable HTML table server side using php and ajax.

The user can make the table or a specific table cell editable with the help of the HTML “contenteditable” attribute.

You just need to add > attribute on any div, td, or any html element that want to make editable element, and user can change the content of the editable element.

Syntax:

>



I am creating table list and able to make td content inline editing with help of jQuery.

Related Post

Also checkout other related tutorials,

Simple Example of Editable Table in HTML5

Let's create a HTML table and make the td editable. The "contenteditable" attribute inside the "<td>" tag of the specific cell you want to edit:

<table id="employee_grid" class="table table-condensed table-hover table-striped bootgrid-table" width="60%" cellspacing="0">
   <thead>
      <tr>
         <th>Name</th>
         <th>Salary</th>
         <th>Age</th>
      </tr>
   </thead>
   <tbody>
      <tr data-row-id="1">
         <td >Tiger Nixon</td>
         <td >320800</td>
         <td >61</td>
      </tr>
      <tr data-row-id="2">
         <td >Garrett Winters</td>
         <td >170750</td>
         <td >63</td>
      </tr>
      <tr data-row-id="8">
         <td >Rhona Davidson</td>
         <td >327900</td>
         <td >55</td>
      </tr>
   </tbody>
</table>
After that you are able to edit column.

Result :

How to Make a Whole Table Editable in HTML?

To make the complete table editable, use the “contenteditable” attribute in the “<table>” element:

<table id="employee_grid"  >
   <thead>
      <tr>
         <th>Name</th>
         <th>Salary</th>
         <th>Age</th>
      </tr>
   </thead>
   <tbody>
      <tr data-row-id="1">
         <td>Tiger Nixon</td>
         <td>320800</td>
         <td>61</td>
      </tr>
      <tr data-row-id="2">
         <td>Garrett Winters</td>
         <td>170750</td>
         <td>63</td>
      </tr>
      <tr data-row-id="8">
         <td>Rhona Davidson</td>
         <td>327900</td>
         <td>55</td>
      </tr>
   </tbody>
</table>

The entire table is now editable. You can change or delete any table cell's data.

Demo & Download Code

Please feel free to send queries to me using below comment section.

View Comments

  • Just editing the cells ... isn't it slightly tasteless :-)?

    As asked in another post, may I ask that here too?

    This will turn interesting with three ingredients :
    - start with an empty grid with just the first (empty) row
    - append rows on demand
    - when the input is finished, treat this grid as a sort of array to make an INSERT into a MySQL table all these rows of records.

    Can you kindly hint how to approach this? Or implement it in the tutorial? Thank you

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More

3 months ago

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

9 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

9 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

9 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

10 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

10 months ago

Categories