HTML
<table>
<tr><th>Name</th><th>etc</th><th>tds</th><th>notes</th></tr>
<tr><td></td><td></td><td></td><td></td></tr>
</table>
JS
$('td').click(function(){
var input = $('<input/>').attr('value',$(this).text());
var w = $(this).innerWidth();
input.css('width',w).css('border','0');
$(this).empty();
$(this).append(input);
input.focusout(function(){$(this).parent().text($(this).val());});
input.focus();
});
この単純なテーブルがあり、ユーザーにテーブルにデータを入力してもらいたいです。ユーザーは td をクリックして値を入力し、4 つのフィールドすべてを入力して Enter キーを押すと、入力した行がサーバーにポストされ、テーブルがリロードされます。
そうするために私はユーザーに考えていました$(this).closest('table').load('tbl.php',{VALUES OF THE TD's in that row});
tbl.php を使用して、行を db に保存し、db からテーブルをリロードして、新しいテーブルをエコー バックします。
私の問題
- td の値を選択して .load() で送信する方法
- ユーザーがEnterキーを押したときにそのイベントをトリガーする方法
どうもありがとう