// Obtain the Control id list containing a string in a container control.
// Parameter: Container Control, id keyword of the control to be searched, and Tag Name of the control to be searched
// Return value: string of the retrieved Control id list, separated by commas.
Copy codeThe Code is as follows:
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 obtain the control in the GridView.
Improvement: you can remove the TagName parameter.
// Obtain the Control id list containing a string in a container control.
// Parameter: id keyword of the container control and control to be searched
// Return value: string of the retrieved Control id list, separated by commas.
Copy codeThe Code is as follows:
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
// Obtain the control array whose id contains a string in a container control
// Parameter: id keyword of the container control and control to be searched
// Return value: the queried control array
Copy codeThe Code is as follows:
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 <re. length; k ++)
{
ReConArry. push (re [k]);
}
}
}
Return reConArry;
}