1.需求
需要实现收银台上添加修改删除商品信息时顾显可以实时看到其变化2.解决
收银台和顾显通过tcp传输进行数据通信,顾显通过操作html中的表格进行数据添加修改和删除操作3.代码
mytest.htmlDynamic Table 名称 颜色 尺寸 单价 折扣 数量 金额dynamic_table.js
onerror=handleErrvar txt=""function handleErr(msg,url,l) { txt="本页中存在错误。\n\n" txt+="错误:" + msg + "\n" txt+="URL: " + url + "\n" txt+="行:" + l + "\n\n" txt+="点击“确定”继续。\n\n" alert(txt) return true}function addRow(name, color, size, unit, discount, count, sum) { var bodyObj=document.getElementById("goods"); if(bodyObj==null) { alert("Body of Table not Exist!"); return; } var rowCount = bodyObj.rows.length; //var cellCount = myarray.length; var newRow = bodyObj.insertRow(rowCount++); newRow.insertCell(0).innerHTML=name; newRow.insertCell(1).innerHTML=color; newRow.insertCell(2).innerHTML=size; newRow.insertCell(3).innerHTML=unit; newRow.insertCell(4).innerHTML=discount; newRow.insertCell(5).innerHTML=count; newRow.insertCell(6).innerHTML=sum;}function removeRow(tbodyID, row) { var bodyObj=document.getElementById(tbodyID); if(bodyObj==null) { alert("Body of Table not Exist!"); return; } var nrow = Number(row); if (nrow在win7 ie10和google 下运行正常
4.备注
1.最好不使用windows自带的记事本,会存在编码问题,推荐使用notepad++,编码为utf8 无bom 2.部分js函数会存在ie下可用,google下不可用,这个代码是通用的
版权声明:本文为博主原创文章,未经博主允许不得转载。
查看更多关于动态添加修改删除html表格内容_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did108618