"H" <nospamplease__henke0001@hotmail.com> wrote in message
news:i8fvb.38604$dP1.142394@newsc.telia.net...[color=blue]
> var v = "place";
> for (var i = 0 ; i < 5 ; i++)
> {
> v = v + i; // or v = "place" +i;
>// Here I want to access the resource in the HTML doc, whos
>//id="place1", id="place2", etc etc, so how can I do that ?
>// like "theValueInv".innerText = "bla bla bla bla"; if the
>//resource with id="place1" is for ewxample a <p>
> }[/color]
Look at:-
<URL:
http://www.jibbering.com/faq/#FAQ4_39 >
-and the linked resource.
But if your interest is on locating elements within a document that have
a specific (and unique, as required) ID then the document.getElementById
function is probably the best option:-
function getEl(id){
if(document.getElementById){ //all DOM browsers
return document.getElementById(id);
}else if(document.all){ //IE 4 fall-back
return document.all[id];
}else if(document.layers){ //Netscape 4
return document.layers[id];//but that will only find positioned
//elements on Netscape 4.
}
return null; //no suitable method exists on this browser.
}
....
var el, v = "place";
for(var c = 0;c < 5;c++){
el = getEl(v+c);
if(el){ //so only if the returned value was non-null.
... //do something with the element.
}
}
....
Richard.