Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric,
 
Paul Phoby
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Destroy anything that stands in your way. Except this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic