自己做的js(三)
来源:互联网 发布:sigmasoft软件 编辑:程序博客网 时间:2024/05/23 19:17
//表动态添加方法
function TableProperty(tname, tableobj1)
{
var tableobjname, tbname = "", otb, itemcount, inputClassArray, inputReadOnlyArray, inputNeedArray, nowcellnum = 0;
this.tableobjname = tableobj1;
this.tbname = tname + "table";
this.otb = $(this.tbname);
this.itemcount = 1;
this.inputClassArray = null;
this.inputReadOnlyArray = null;
this.inputNeedArray = null;
this.nowcellnum = 0;
}
//格式化内容
TableProperty.prototype.FormatTable = function(inputArray1, inputArray2, inputArray3)
{
this.inputClassArray = inputArray1;
this.inputReadOnlyArray = inputArray2;
this.inputNeedArray = inputArray3;
}
//添加一行
TableProperty.prototype.AddRow = function()
{
var otr = this.otb.insertRow(this.itemcount);
otr.id = this.tbname + "_row_" + this.itemcount;
otr.style.backgroundColor = "white";
this.itemcount = this.itemcount + 1;
this.nowcellnum = 0;
}
//填写一行
TableProperty.prototype.SetTable = function()
{
var formatintext = new FormatInputText();
for(var i = this.nowcellnum; i<this.inputClassArray.length; i++)
{
var ocell = this.otb.rows(this.itemcount - 1).insertCell(i);
var readonly = "";
if(this.inputReadOnlyArray[i] == "true")
readonly = "true";
switch (this.inputClassArray[i])
{
case "numpoint":
ocell.innerHTML = formatintext.getNumPoint(this.tbname + "_row_" + (this.itemcount - 1) + "_cell_" + (i + 1), "width: 97%; background-color: white;", "input2", readonly, (this.itemcount - 1).toString());
break;
case "common":
ocell.innerHTML = formatintext.getCommonText(this.tbname + "_row_" + (this.itemcount - 1) + "_cell_" + (i + 1), "width: 97%; background-color: white;", "input2", readonly);
break;
default:
break;
}
ocell.className = cellclass;
this.nowcellnum++;
}
}
//添加删除按钮
TableProperty.prototype.AddDelButton = function()
{
var ocell = this.otb.rows(this.itemcount - 1).insertCell(this.nowcellnum);
ocell.className = cellclass;
ocell.style.textAlign = "center";
ocell.innerHTML = "<img src='" + delImgAddress + "' onclick=/"" + this.tableobjname + ".DelRow(" + (this.itemcount - 1) + ")/"></img>";
this.nowcellnum++;
}
//删除一行
TableProperty.prototype.DelRow = function(rownum)
{
for(var i = rownum; i<this.itemcount - 1; i++)
{
for(var j = 0; j<this.inputClassArray.length; j++)
{
$(this.tbname + "_row_" + i + "_cell_" + (j + 1)).value = $(this.tbname + "_row_" + (i + 1) + "_cell_" + (j + 1)).value;
}
}
this.otb.deleteRow(this.itemcount - 1);
this.itemcount--;
}
//删除所有行
TableProperty.prototype.DelAllRow = function()
{
for(var i = this.itemcount - 1; i>0; i--)
{
this.otb.deleteRow(i);
this.itemcount--;
}
this.nowcellnum = 0;
}
//读取表的值
TableProperty.prototype.readtablecont = function()
{
var tablecont = "";
var rowcount = this.otb.rows.length;
for(var i = 0; i < this.itemcount - 1; i++)
{
for(var j = 0; j < this.inputClassArray.length; j++)
{
tablecont = tablecont + Trim($(this.tbname + "_row_" + (i + 1) + "_cell_" + (j + 1)).value);
if(j == this.inputClassArray.length - 1)
{
tablecont = tablecont + rowspl;
}
else
{
tablecont = tablecont + cellspl;
}
}
}
return tablecont;
}
//检查必填项
TableProperty.prototype.checkNeedInput = function()
{
for(var i = 1; i<this.itemcount; i++)
{
for(var j = 0; j<this.inputClassArray.length; j++)
{
if(this.inputNeedArray[j] == "true")
{
if($(this.tbname + "_row_" + i + "_cell_" + (j + 1)).value == "") return false;
}
}
}
return true;
}
//普通增加行
TableProperty.prototype.commonAdd = function()
{
this.AddRow();
this.SetTable();
this.AddDelButton();
}
//增加内容
TableProperty.prototype.addContext = function(tablecont)
{
//alert(tablecont);
this.rowcont = tablecont.split(rowspl);
if(this.rowcont[0] == "") this.rownum = 0;
else if(this.rowcont[1] == "") this.rownum = 1;
else this.rownum = this.rowcont.length;
for(var i = 0; i<this.rowcont.length; i++)
{
this.AddRow();
this.SetTable();
this.AddDelButton();
var cellcont = this.rowcont[i].split(cellspl);
for(var j = 0; j<cellcont.length; j++)
{
$(this.tbname + "_row_" + (i + 1) + "_cell_" + (j + 1)).value = cellcont[j];
}
}
}
- 自己做的js(三)
- 自己做的js(一)
- 自己做的js(二)
- 自己练习做的一些效果图《三》
- 自己做的萌萌哒的js宠物挂件~
- 自己做自己的饭
- 做最好的自己
- 做自己的操作系统
- 自己做的iptables
- 做最好的自己
- 做自己的GenerateCode
- 做自己的事情
- 做最好的自己
- 做最好的自己
- 做最好的自己
- 做永远的自己
- 做最好的自己
- 做最好的自己
- VC6中使用for_each和mem_fun遇到问题的解决办法
- 结构体成员排序
- 解析Makefile --- 简单的Makefile示例
- Java开发环境的配置
- 新的一年
- 自己做的js(三)
- Swing校验
- 由于更改数据库服务器名称造成的错误
- Java开发工具介绍
- 一个比较好用的日历控件
- 人机猜数游戏
- Daniel Mendoza 丹尼尔.门多萨
- 前面发的js的配置文件
- 终于搞掂Caepero.dll