// 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.
CopyCode The 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;
}
it can be used to obtain the control in the gridview.
improvement: you can remove the tagname parameter
// obtain the Control ID list of a container control containing a string.
// parameter: container Control and the ID keyword of the control to be searched
// return value: string of the Control ID list found, separated by commas. copy Code the code is as follows: function getidlistbysubkey (container, subidkey)
{< br> var idlist = "";
for (VAR I = 0; I {< br> If (container. childnodes [I]. attributes! = NULL & container. childnodes [I]. attributes ["ID"]! = Undefined & container. childnodes [I]. id. indexof (subidkey)>-1)
{< br> idlist + = container. childnodes [I]. ID + ",";
}< br> If (container. childnodes [I]. childnodes. length> 0)
{< br> idlist + = getidlistbysubkey (container. childnodes [I], subidkey)
}< BR >}< br> return idlist;
}
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: container Control and the ID keyword of the control to be searched
// return value: the queried control array copy Code the code is as follows: function getconlistbysubkey (container, subidkey)
{< br> var reconarry = [];
for (VAR I = 0; I {< br> If (container. childnodes [I]. attributes! = NULL & container. childnodes [I]. attributes ["ID"]! = Undefined & container. childnodes [I]. id. indexof (subidkey)>-1)
{< br> reconarry. push (container. childnodes [I]);
}< br> If (container. childnodes [I]. childnodes. length> 0)
{< br> var Re = getconlistbysubkey (container. childnodes [I], subidkey)
for (VAR K = 0; k {< br> reconarry. push (Re [k]);
}< BR >}< br> return reconarry;
}