2005年的时候开发了一个WEB应用程序,前端技术用了自己写的javascript脚本。我用javascript脚本动态地向table中增加行,每行里面有一些input框,例如:id[]、name[]、price[]等等。程序当时在ie6,firefox下都调试正常,所有程序开发完后经过3个月测试,也没发现任何问题。所以将软件进行推广,在集团内40多个机构使用。半年左右发现某些机构中的数据出现错乱,反复查找程序都没有找到什么问题。情况如下:例如一组这样的数据:
id[] name[] price[]
22 西瓜 1.5
25 东瓜 1.2
29 南瓜 0.8
38 北瓜 1.9我会将这4组数据插入到数据库,我用自己的电脑怎么都没出现过问题。不过客户的电脑插入到数据库后常常出现这样的情况:id[] name[] price[]
25 西瓜 1.5
22 东瓜 1.2要么id错位,要么名字或价格错位。不知道是javascript的问题,还是浏览器问题。还是在用php程序得到表单数据的时候有问题。为什么偶尔会错位,只是偶尔。为什么有些客户端运行三、四年都没出现过一次这样的问题,为什么有些客户端常常出问题。可能出现的问题会是在哪里?
id[] name[] price[]
22 西瓜 1.5
25 东瓜 1.2
29 南瓜 0.8
38 北瓜 1.9我会将这4组数据插入到数据库,我用自己的电脑怎么都没出现过问题。不过客户的电脑插入到数据库后常常出现这样的情况:id[] name[] price[]
25 西瓜 1.5
22 东瓜 1.2要么id错位,要么名字或价格错位。不知道是javascript的问题,还是浏览器问题。还是在用php程序得到表单数据的时候有问题。为什么偶尔会错位,只是偶尔。为什么有些客户端运行三、四年都没出现过一次这样的问题,为什么有些客户端常常出问题。可能出现的问题会是在哪里?
解决方案 »
- 请问这句话的意思
- 联动下拉框的问题
- history.go("string");问题--不起作用
- 谁能提供js+div的一些效果?
- UltraWebGrid的客户端新增行,大家帮看一下还应怎么做?
- (急)为什么显示不了呢?
- 总说缺少对象,是什么原因?如何改??关于swapimage
- 请问用javascript使html页面的后退功能失效!
- 怎样在某个表格的单元格中添加滚动条???
- ----------------dataTable-------分页的问题---------------------
- JS控制图片路径斜扛问题!
- 保存cookie时,为何要先进行encodeURI()编码呢?读取时再进行decodeURI()解码,为什么这样做呢?是为了信息保密吗?这样做也无法起到保密的作用呀,因为随机可以解码后读出来呀?
/** Add a line of depotin table. */
function add_item(obj,article_id,article_coding,article_name,parent_id,articlecat_langname,article_size,article_unit,frm,amount,max_price)
{
var row,cell,str;
row = eval("window.parent.parent.document.all["+'"'+obj+'"'+"]").insertRow(-1);
if(row != null )
{
cell = row.insertCell(0);
str="<input type='hidden' name='article_id[]' value='"+article_id+"'><input type='hidden' name='max_price[]' value='"+max_price+"'><input type='text' style='width:65px' name='article_coding[]' value='"+article_coding+"' class='disabled' readonly>"
cell.innerHTML=str; cell = row.insertCell(1);
str="<input type='text' style='width:70px' name='article_name[]' value='"+article_name+"' class='disabled' readonly>"
cell.innerHTML=str; cell = row.insertCell(2);
str="<input type='hidden' name='parent_id[]' value='"+parent_id+"'><input type='text' style='width:65px' name='articlecat_langname[]' value='"+articlecat_langname+"' class='disabled' readonly>"
cell.innerHTML=str; cell = row.insertCell(3);
str="<input type='text' style='width:65px' name='article_size[]' value='"+article_size+"' class='disabled' readonly>"
cell.innerHTML=str; cell = row.insertCell(4);
str="<input type='text' style='width:68px' name='article_productiondate[]' value=''>"
cell.innerHTML=str; cell = row.insertCell(5);
str="<input type='text' style='width:40px' name='article_durability[]' value=''>"
cell.innerHTML=str; cell = row.insertCell(6);
str="<input type='text' style='width:40px' name='article_unit[]' value='"+article_unit+"' class='disabled' readonly>"
cell.innerHTML=str; cell = row.insertCell(7);
str="<input type='text' style='width:40px' name='article_number[]' autocomplete='off' onFocus='this.select()' onkeydown=doKeyDown(event,'"+frm+"',this) onKeyUp=count_price('"+frm+"',this,'"+amount+"');>"
cell.innerHTML=str; cell = row.insertCell(8);
str="<input type='text' style='width:40px' name='article_price[]' autocomplete='off' onKeyUp=count_price('"+frm+"',this,'"+amount+"');>"
cell.innerHTML=str; cell = row.insertCell(9);
str="<input type='text' style='width:50px' name='article_amount[]' autocomplete='off' value='0.00' onblur='javascript:this.value=Math.round(parseFloat(this.value)*100)/100' onKeyUp=count_amount('"+frm+"','"+amount+"',this);>"
cell.innerHTML=str; cell = row.insertCell(10);
str="<input type='text' style='width:65px' name='article_re[]'><input type='checkbox' name='[]' value='"+article_id+"' class='checkbox' />"
cell.innerHTML=str;
}
}
/** Delete a line of table. */
function delete_item(id, name, obj, amount)
{
var parent = document.getElementById(id);
if (!parent)
{
return;
} var rb = parent.getElementsByTagName('input'); var rowNum,curRow;
for (var r = 0; r < rb.length; r++)
{
if (rb[r].name.substr(0, name.length) == name)
{
if (rb[r].checked == true)
{
curRow = rb[r].parentNode.parentNode;
rowNum = eval("document.all."+obj).rows.length - 1;
eval("document.all["+'"'+obj+'"'+"]").deleteRow(curRow.rowIndex);
}
}
}
count_amount(id, amount,'0');
}
if (rb[r].name.substr(0, name.length) == name)
判断这个的时候name是唯一的吗?如果出现重名会怎样?
ID NAME PRICE
22 西瓜 1.2
23 西瓜 1.3
那你只删除其中PRICE为1.2的西瓜时不是就出错了吗?
不会出现这种情况,id 和 name不能都一样的。有如下的情况:
ID NAME PRICE
22 西瓜 1.2
22 西瓜 1.2 复选框选中的才会被删除