me********@gmail.com wrote:
Hello, can any body help me out..
I have some td element which have following ids
ctl1_lnkPrint
ctl2_lnkPrint
ctl3_lnkPrint
ctl4_lnkPrint
ctl5_lnkPrint
..
..
..
and i just know the "lnkPrint", so i have to use wildcard characters...
(something like *lnkPrint)
I want to trap all TD elements with the above sequence id from the html
document (using getElementbyID....) and replace those td element with
blank td element...
Can anybody give me javascript of above scenario....
Thanks in Advance
Meehir
Meehir
Those Id's look very asp.net to me!
It's possible to write those Id's to a javascript var from your
codebehind. As this is a javascript group I will not go into too much
detail. As a side note this is one of the reasons i stopped using
asp.net.
----------------- C# CODE -----------------
string cJavascript = "var aIDs = [";
// at this point you need to cycle through your Serverside objects and
// using their .ClientID attrib build a string that represents a
// javascript array. i.e. "var cIDs = ['foo', 'bar'];"
// Then add it to the page
this.Page.RegisterClientScriptBlock("uniqueServerS ideKey", "<script
type=\"text/javascript\">" + cJavascript + "</script>");
-------------------------------------------
This will add the array to the page. So you could cycle through the
array to obtain your elemnts.
----------------- JS CODE -----------------
for( var i = 0; i < aIDs.length; i++ )
{
var eElement = document.getElementById(aIDs[i]);
}
-------------------------------------------
Having said that it is possible to obtain it them using just javascript.
If the containing table has an ID that you know you could use :
var etable = document.getElementsById("IdOfTable");
var aCells = etable.getElementsByTagName("td");
This will then return ALL the cells of the table that you can apply
logic to in order to ensure you have the correct elements and then to do
what you want with them.
HTH
Andy