更改行值onclick html表,如phpMyAdmin

Cur*_*ewe 1 html php mysql ajax

我基本上试图使用一种简单的方法来编辑存储在mySQL数据库中的表,但是不想通过不同的编辑页面,所以我的理论是:

像往常一样显示HTML表格中的所有数据.

<table class="table table-bordered sortable">
<thead>
        <tr>
                <th>Marchant</th>
                <th>URL</th>
                <th>Status</th>
                <th>Sold</th>
                <th>Deals</th>
                <th>Sites</th>
                <th>Found</th>
                <th>Seen</th>
        </tr>
</thead>

<tbody>
        <tr>
                <td>value</td>
                <td></td>
                <td></td>
                <td>Sold here</td>
                <td>Deals here</td>
                <td>Sites here</td>
                <td>null</td>
                <td>null</td>
        </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我希望能够动态编辑数据,只需单击显示的值并进行更改即可.

问题是如何通过这样做,甚至可能吗?

nic*_*ass 5

如果您正在使用jQuery,请查看就地编辑插件(jEditable是一个很好的插件).

这背后的想法是在表格单元格上设置一个click事件监听器,在其中添加一个带有TD内容的可编辑textarea/form.

在更改或提交时,数据通过ajax请求发送到服务器,服务器更新数据库并最终返回已清理的数据(用它更新TD内容).