//push add a new item into Array
if(typeof(Array.prototype.push)!="function")
Array.prototype.push = function(item){
this[this.length] = item; return this.length;};你自己加嘛
if(typeof(Array.prototype.push)!="function")
Array.prototype.push = function(item){
this[this.length] = item; return this.length;};你自己加嘛
for (i=1;i<=tRows;i++) { // tRows表示动态表格生成行数
a = eval("frm.txtNumber" + i + ".value");
b = eval("frm.txtUnitPrice" + i + ".value");
tv.push[a,b]; //这里的push怎么代替?
frm.txtTotal.value = updateTotal();
}
function updateTotal() {
var i, len = tv.length;
var total=0;
for (i = 0; i < len; i++) {
total += tv[i][0]*tv[i][1];
}
return total;
}
if(typeof(Array.prototype.push)!="function")
{
Array.prototype.push = function()
{
for (var i=0; i<arguments.length; i++)
this[this.length] = arguments[i];
return this.length;
};
}tv.push(a, b);
sorry, 应该是 tv.push([a,b]) 我写成了 tv.push(a,b)
不是组织其实上例中的tv.push(a,b)等于tv.push(frm.txtNumber1.value,frm.txtUnitPrice1.value);
tv.push(frm.txtNumber2.value,frm.txtUnitPrice2.value);
tv.push(frm.txtNumber3.value,frm.txtUnitPrice3.value);
.
.
.
tv.push(frm.txtNumber n .value,frm.txtUnitPrice n .value);