Connecting Tech Pros Worldwide Forums | Help | Site Map

How to get the object ids of all the tables and use them to invoke a function of the object.

Eshrath Ali Khan
Guest
 
Posts: n/a
#1: Jul 23 '05

Hi,

I have a requirement where I am creating table object with different
ids using XSL by taking an XML as input. The no of objects (tables) is
not fixed. I want to write a javascript to invoke all these objects. I
can pass the number of objects (Tables) available in the documents as a
parameter to the javascript function. Can you please tell me how to
invoke all those objects.

Basically these objects are nothing but a active X controls writte
in .Net. I need to get the object ids of these objects and invoke a
function of the object. The function name is DrawTable().

I am just stating the example for one object, the object name is
'tablecontrol1' and the javascript I have written is

<script type="text/javascript">
function invokeTableControl()
{
tablecontrol1.DrawTable();
}
</script>

I want to write a generalized script to invoke all the objects
(tables) in the document.

<script type="text/javascript">
function invokeTableControl(noofobjects)
{
for (i=0;i<noofobjects;i++)
{
// but i donno what to write here. any ptrs to
//this would be helpful.
}
}
</script>

I donno how to invoke all the other objects. In the XSL I would be
giving the ids of the tables as tablecontrol1,
tablecontrol2,tablecontrol3,....


thanks
-Eshrath.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Joakim Braun
Guest
 
Posts: n/a
#2: Jul 23 '05

re: How to get the object ids of all the tables and use them to invoke a function of the object.


"Eshrath Ali Khan" <eshrath@gmail.com> skrev i meddelandet
news:418ffbfe$0$14555$c397aba@news.newsgroups.ws.. .[color=blue]
>
> Hi,
>
> I have a requirement where I am creating table object with different
> ids using XSL by taking an XML as input. The no of objects (tables) is
> not fixed. I want to write a javascript to invoke all these objects. I
> can pass the number of objects (Tables) available in the documents as a
> parameter to the javascript function. Can you please tell me how to
> invoke all those objects.
>[/color]
<snip>

Use DOM. Like this (add checks for browser's DOM compatibility):

var theTables = document.getElementsByTagName("table");

// theTables is now a loopable array with a length property:
invokeSomeFunction(theTables.length);

for(var i = 0, max = theTables.length; i < max; i++){

invokeSomeOtherFunction(theTables[i].id);
}

Joakim Braun


Closed Thread