1、增加表格就不多讲了,用jquery的append方法
2、删除行
例子:tr下的td里有个input type="radio",所以要移除此行,先获取选中的radio,
function doDelete(){
var checked = $("input[type='radio']:checked");
if(checked.attr("checked")==true) //注意:此处判断不能用$(this).attr("checked")==‘true'来判断。
{
checked.parent().parent().remove();
}
}
3、获取此行的索引
onBlur='isExits(this)'
function isExits(obj){
//先要判断当前行的kind和code不为空
//alert($("#usertable tr:eq("+$(obj).parent().parent().index()+")>td:eq(2)>input").val());
//得采用ajax调用
$.ajax({
type: "POST",
url: "<%= basePath%>czsf/xtgl/dmgl/DmglServlet",
data: {'status':'ifexists','kind':$("#usertable tr:eq("+$(obj).parent().parent().index()+")>td:eq(1)>input").val(),'code':$("#usertable tr:eq("+$(obj).parent().parent().index()+")>td:eq(2)>input").val()}, //在后台获取本单位的代码
success: function(msg){
if(msg){
alert("该类别的代码已存在!");
$("#usertable tr:eq("+$(obj).parent().parent().index()+")>td:eq(2)>input").val('');
}
}
});
}