Click to See Complete Forum and Search --> : innerHtml question


pelegk1
10-16-2003, 01:44 AM
i am trying to do this :

function WriteCitys(){
for (i=0,count=0;i<maxCity;++i,++count){
if (i<tmpCityList.length) {
cityList[count]=tmpCityList[i];
tmpStr='<font face="Arial" size="6"><a href="JavaScript:Submit(cityList[0])">';
tmpStr+=tmpCityList[i]+'</a></font>';
document.all["tdCity"+count].innerHtml=tmpCityList[i];
}
}

what i try to do : is to read a cty from an array list and then
i try towrite into a td!
the problem that it dosent effect at all!
its only effects when i use : innerText!
bu then it dosent make a linkor use the font type!
what to do?
thanks in advance
Peleg

Khalid Ali
10-16-2003, 02:04 AM
Change this line
document.all["tdCity"+count].innerHtml=tmpCityList[i];

to this

document.getElementById("tdCity"+count).innerHtml=tmpCityList[i];

more importantly..make sure you have tdCity+count id 's assigned

pelegk1
10-16-2003, 02:07 AM
beacuse when i use innerText i does change all the td's
but not using the font and the herf that i need:(
what else can i do?
thanks
peleg

Gollum
10-16-2003, 02:09 AM
It's more likely that you need to spell "innerHtml" as "innerHTML". The case is important.

pelegk1
10-16-2003, 02:10 AM
that solvedthe problem!
but why sometimes the properties are case sensetive and sometimes not?

Khalid Ali
10-16-2003, 02:18 AM
LOL..Gollum..darn I can not believe I missed the spellings..I guess I better hit the bed now,its 1:14 AM in here..darn computers:D

Gollum
10-16-2003, 02:40 AM
heh heh, I get days like that :D

pelegk1 - in answer to your question, JavaScript is a case-sensitive language, HTML on the other hand is case-insensitive so you are free to use whatever case you like for attributes in HTML, but not in JS.

pelegk1
10-16-2003, 03:11 AM
thanks alot!

Khalid Ali
10-16-2003, 07:55 AM
Originally posted by Gollum
HTML on the other hand is case-insensitive so....

Just a little addition,As of now a days,XHTML requires that all the attribute names and their corresponding values be in lower case,heck even elements names be in lower case.
I think in near future HTML style coding will be obsolete, Point is its a good practice to use lower case evenin html as well

ccoder
10-16-2003, 09:16 AM
pelegk1

This is really OT, but in your tag line - holy only has one "l".

Holly is a tree. If you have never seen it, here is one of the better pictures that I could find on the web - http://www.uksafari.com/holly.htm

pelegk1
10-19-2003, 01:30 AM
that when it was in small letters it didnt work for me!
from which versiob of browser it will work as u say?