• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How To add a 'class'(of css file) dynamically through javascript

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
objRow = document.all.item("tblcollgroup").insertRow()
objCell = objRow.insertCell();
objCell.innerHTML ='<td width="20%" align="center" class="lbl">' + currRows + '</td>'

In the above code i want to add the class'lbl' to the current cell. But i am not able to do it. How can i do this ? It is very urgent for me.
[ September 19, 2002: Message edited by: Paul Phoby ]
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Paul Phoby:
objRow = document.all.item("tblcollgroup").insertRow()
objCell = objRow.insertCell();
objCell.innerHTML ='<td width="20%" align="center" class="lbl">' + currRows + '</td>'

In the above code i want to add the class'lbl' to the current cell. But i am not able to do it. How can i do this ? It is very urgent for me.
[ September 19, 2002: Message edited by: Paul Phoby ]



objCell.className = "lbl"
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u,Charlie Sturman,
I am very happy for your immediate answer
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the same code, cant I directly put the class and other attributes in the <td> tag.
My main concern is, I dont want to set the class and other attributes in the html tag itself not out side of the innerHTML.
I think you got the problem ?
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the same code, cant I directly put the class and other attributes in the <td> tag ?
My main concern is,
1 > I dont want to set the class and other attributes in the html tag itself not out side of the innerHTML.
2> I want to give the functions also in the <td> tag not by using the attachevent.

I think you got the problem ?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should be able to do something like this
objCell.style.::::="blah"
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
I dont want to use the
objCell.style
I need attributes should come inside the <td> tag only.
Question:
Do you have any function which i can use for adding rows dynamically. ?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally do not build tables in tht manner...I do it all with innerHTML...Here is an example how I do it.
http://www10.brinkster.com/a1ien51/Scripts/Cart.htm
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic