//Get the list of control IDs whose id contains a certain string in a container control
//Parameters: container control, id keyword of the control to be found, label name of the control to be found
//Return value: List string of found control IDs, separated by commas.
function GetIdListBySubKey(container,subKey,TagName)
{
var idList = "";
for(var i = 0; i < container.childNodes.length;i )
{
if(container.childNodes[i].nodeName == TagName && container.childNodes[i].id.indexOf(subKey) > -1)
{
idList = container.childNodes[i].id ",";
}
if( container.childNodes[i].childNodes.length > 0)
{
idList = GetIdListBySubKey(container.childNodes[i],subKey,TagName)
}
}
return idList;
}
can be used to get the controls in GridView.
Improvement: The TagName parameter can be removed
//Get the list of control ids whose id contains a certain string in a container control
//Parameters: container control, id keyword of the control to be found
/ /Return value: The found control ID list string, separated by commas.
function GetIdListBySubKey(container,subIdKey)
{
var idList = "";
for(var i = 0; i < container.childNodes.length;i )
{
if(container.childNodes[i].attributes != null && container.childNodes[i].attributes["id"] != undefined && container.childNodes[i].id.indexOf(subIdKey) > -1)
{
idList = container.childNodes[i] .id ",";
}
if(container.childNodes[i].childNodes.length > 0)
{
idList = GetIdListBySubKey(container.childNodes[i],subIdKey)
}
}
return idList;
}
For example: GetIdListBySubKey(document,"txt_Money")
Improvement: directly return the control array
// Get the control array whose id contains a certain string in a container control
// Parameters: container control, id keyword of the control to be found
// Return value: array of found controls
function GetConListBySubKey(container,subIdKey)
{
var reConArry = [ ];
for(var i = 0; i < container.childNodes.length;i )
{
if(container.childNodes[i].attributes != null && container.childNodes[i] .attributes["id"] != undefined && container.childNodes[i].id.indexOf(subIdKey) > -1)
{
reConArry.push(container.childNodes[i]);
}
if(container.childNodes[i].childNodes.length > 0)
{
var re = GetConListBySubKey(container.childNodes[i],subIdKey)
for(var k = 0;k{
reConArry.push(re[k]);
}
}
}
return reConArry;
}