php实时编辑表单,实时编辑表格,可以编辑的表格

for($colIndx=0;$colIndx<5;$colIndx++){

?>

"><?phpecho "Column $colIndx"?>

} ?>

for($rowIndx=0;$rowIndx<5;$rowIndx++){

?>

">

for($colIndx=0;$colIndx<5;$colIndx++){

?>

<?php  echo"R".$rowIndx."C".$colIndx?>

} ?>

} ?>

$(document).ready(function () {

$("#editTable tbody td").liveeditor({

editingCss: 'editing',

// Scroll to focused editor

onEditorFocused: function () {

var $window = $(window);

var $body = $('html, body');

var elem = $(this);

var elemTop = elem.offset().top;

var elemLeft = elem.offset().left;

var windowWidth = $window.width();

var windowHeight = $window.height();

var docViewTop = $window.scrollTop();

var docViewLeft = $window.scrollLeft();

var scrollVertical = (elemTop + elem.height() > docViewTop + windowHeight) || (elemTop < docViewTop);

var scrollHorizontal = (elemLeft + elem.width() > docViewLeft + windowWidth) || (elemLeft < docViewLeft);

if (scrollVertical && scrollHorizontal) {

//Scroll diagonally

$body.stop()

.animate({

scrollTop: (elemTop - windowHeight / 2) + 'px',

scrollLeft: (elemLeft - windowWidth / 2) + 'px'

}, 'fast');

} else if (scrollVertical) {

//Scroll vertically

$body.stop()

.animate({

scrollTop: (elemTop - windowHeight / 2) + 'px'

}, 'fast');

} else {

//Scroll horizontally

$body.stop()

.animate({

scrollLeft: (elemLeft - windowWidth / 2) + 'px'

}, 'fast');

}

},

//Track changes on row level

onChanged: function () {

var row = $(this).closest('tr');

if ($('.liveeditor-changed',row).length > 0)

row.addClass('changed');

else

row.removeClass('changed');

}

});

//Save changes

$('#saveButton').click(function () {

$.liveeditor.closeEditor($("#editTable tbody td"));

var headers = $('#editTable thead tr th');

$('#editTable tbody tr.changed').each(function () {

var row = $(this);

var data = "row=" + row.attr("row") + "&" + $.liveeditor.serialize($('td', row), headers);

$.ajax({

type:"POST",

url: "ajax.php",

data: data,

success: function(data){

$('#ajaxResponses').append("

" + data + "

");

$.liveeditor.reset($("#editTable tbody td"));

},

error: function(){

console.log("Failed to save changes");

}

});

});

});

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值