我有一些数据库记录显示在表格行和列中。 我用纯文本显示这些信息。但是我想在用户点击它们时将它们更改为文本框,并在光标模糊时更新内容。 我希望我能说出我的意思。将文本更改为文本框后更新纯文本
有人帮我吗?
我有一些数据库记录显示在表格行和列中。 我用纯文本显示这些信息。但是我想在用户点击它们时将它们更改为文本框,并在光标模糊时更新内容。 我希望我能说出我的意思。将文本更改为文本框后更新纯文本
有人帮我吗?
以下是站点和/或项目,以帮助你完成你的任务引用。
http://www.mysqlajaxtableeditor.com/
http://www.phpclasses.org/package/3104-PHP-Edit-data-in-an-HTML-table-using-AJAX.html
http://www.9lessons.info/2011/03/live-table-edit-with-jquery-and-ajax.html
谢谢乔治。你是对的,我没有提到我用过的语言。我的项目正在运行PHP和MySQL。第三个链接就是我的意思。 –
要打开一个表格单元格中的内容为测试输入:
//bind event handler to click event for all table cells
$('td').on('click', function() {
//cache this table cell in a variable
var $table_cell = $(this);
//add a text input with the text of this table cell,
//then select that text input, focus it (so the user doesn't have to click on the text box to gain focus),
//then add an event handler to the text input for the blur event
$table_cell.html('<input type="text" value="' + $table_cell.text() + '" />').children('input').focus().bind('blur', function() {
//run your code to update the text within this <td> element
//sent a POST request to your server-side script with the value of the text-input
$.post('path_to/server/script.php', $(this).serialize(), function (response) {
//here you get the response from the server and you can update the table cell
//if the response from the server is the new text for the cell then you can do this...
$table_cell.text(response);
});
});
});
如果你正在寻找在线编辑,也有大量的可用插件。
这一个看起来很有希望http://www.appelsiini.net/projects/jeditable(没试过)
这将是有益的,如果你能告诉我们一些代码,也许尝试你做?另外你使用什么语言进行服务器端编码,以便我们可以指出你有用的资源? –
@Mhamhammad尝试发布一些代码,它很难理解你想要什么,也许代码会帮助我们帮助你。 – Iznogood