在php + ajax中编辑表值

时间:2016-04-27 20:31:29

标签: javascript php jquery mysql

我的桌子是这样的:

<table class="table table-striped table-hover table-bordered" id="sample_editable_1">
                        <thead>
                        <tr>
                            <th>
                                 Eventname
                            </th>
                            <th>
                                 Time
                            </th>
                            <th>
                                Parsed Channel
                            </th>
                            <th>
                                 Real Channel
                            </th>
                            <th>
                                 Edit
                            </th>
                            <th>
                                 Delete
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
 <?php while ($row = $req_events_parse->fetch()) {  
  echo"<td>
                    ".$row['eventname']."
                            </td>
                            <td>
                                 ".$row['datetime']."
                            </td>
                            <td>
                                 ".$row['twchannel']."
                            </td>
                            <td class='center'>
                                 ".$row['realchannelname']."
                            </td>
                            <td>
                                <a class='edit' href='javascript:;'>
                                Edit </a>
                            </td>
                            <td>
                                <a class='delete' href='javascript:;'>
                                Delete </a>
                            </td>
                        </tr>";
}
?>
                        </tbody>
                        </table>

我有jscript,在buttonclick上我可以编辑表数据但只保留在html中,脚本的主要部分是这样的:

  table.on('click', '.edit', function (e) {
        e.preventDefault();


        var nRow = $(this).parents('tr')[0];

        if (nEditing !== null && nEditing != nRow) {

            restoreRow(oTable, nEditing);
            editRow(oTable, nRow);
            nEditing = nRow;
        } else if (nEditing == nRow && this.innerHTML == "Save") {

            saveRow(oTable, nEditing);
            nEditing = null;
            alert("Updated!");
        } else {

            editRow(oTable, nRow);
            nEditing = nRow;
        }
    });
}

我的问题是,如何从我正在编辑的行获取值,我想获取这些值并将它们发送到我的php脚本,这将更新mysql数据库。

0 个答案:

没有答案