var modifyvalue;
var actTN ;
mofidycolumn=function(tn,ischkd){//tn-表名,ischkd是否选中
if(ischkd.checked){//获取选中的项
if (actTN == ""){//下拉列表值是否是默认值
actTN = tn;
modifyvalue = tn+","+ischkd.value;//添加选中项
}
else
{
if(actTN == tn){//是否选中下拉列表的其他值
modifyvalue += ","+tn+","+ischkd.value;
}
else{//是则清空
modifyvalue="";
}
}
return true;
}
else{
//?复选框从选中状态变成为未选中状态,存在字符串内的值怎么删除????
return false;
}
}
var actTN ;
mofidycolumn=function(tn,ischkd){//tn-表名,ischkd是否选中
if(ischkd.checked){//获取选中的项
if (actTN == ""){//下拉列表值是否是默认值
actTN = tn;
modifyvalue = tn+","+ischkd.value;//添加选中项
}
else
{
if(actTN == tn){//是否选中下拉列表的其他值
modifyvalue += ","+tn+","+ischkd.value;
}
else{//是则清空
modifyvalue="";
}
}
return true;
}
else{
//?复选框从选中状态变成为未选中状态,存在字符串内的值怎么删除????
return false;
}
}
L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js.Array.removeByValue.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body> <script type="text/javascript">
<!--
Array.prototype.removeByValue = function(value)
{
var valueIndex = -1; for (var i=0; i<this.length; i++)
{
if (value == this[i])
{
valueIndex = i;
break;
}
} if (valueIndex > -1)
{
this.splice(valueIndex, 1);
}
};var tableList = new Object();// 添加列名。
function addColumnName(tableName, columnName)
{
if (tableList[tableName] == undefined)
{
// 添加表名
tableList[tableName] = new Array();
} // 添加列名
tableList[tableName].push(columnName);
}// 删除列名。
function removeColumnName(tableName, columnName)
{
if (tableList[tableName])
{
tableList[tableName].removeByValue(columnName); if (tableList[tableName].length == 0)
{
tableList[tableName] = undefined;
}
}
}function showResult()
{
var result = ""; for (var tn in tableList)
{
if (tableList[tn])
{
if (result != "")
{
result += ";" + tn + ":" + tableList[tn];
}
else
{
result = tn + ":" + tableList[tn];
}
}
} return result;
}addColumnName("Admin", "AdminName");
addColumnName("Admin", "AdminAge");addColumnName("User", "UserName");
addColumnName("User", "UserAge");
addColumnName("User", "UserGender");// 删除列名。
removeColumnName("User", "UserAge");alert(showResult());// 再删两项。
removeColumnName("User", "UserName");
removeColumnName("User", "UserGender");alert(showResult());
//-->
</script>
</body>
</html>