Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Changing values in a TD tag

Reply
Thread Tools

Changing values in a TD tag

 
 
Filip Matošić
Guest
Posts: n/a
 
      11-30-2004
I wont to change the text (something) colour in a td tag.

<table> <tr><td>something</td></tr></table>
I have a form which validates and i wont to (if the field is incorrect)
change the txt colour in front
of the txt field . I dont know how to reach the text from javascript?


 
Reply With Quote
 
 
 
 
RobB
Guest
Posts: n/a
 
      11-30-2004
"Filip Matošić" <(E-Mail Removed)> wrote in message news:<cohjk5$j9p$(E-Mail Removed)>...
> I wont to change the text (something) colour in a td tag.
>
> <table> <tr><td>something</td></tr></table>
> I have a form which validates and i wont to (if the field is incorrect)
> change the txt colour in front
> of the txt field . I dont know how to reach the text from javascript?


Well...for starters, it's not a 'tag' - not once it shows up on the
screen. By then it's an object, and you can 'get' it for programming
by several methods; probably the easiest is to simply id it, and use:

document.getElementById('cell id') //no spaces!

....and then change its style.color property to what you'd like.

document.getElementById('somecell').style.color = '#f00';
 
Reply With Quote
 
 
 
 
Filip Matosic
Guest
Posts: n/a
 
      12-01-2004
THX works fine, but i thought it was a tag, aren't all html elements tags
(TD, TABLE, TR .....). Do you mean that as an object its an instance of the
table?
"RobB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Filip Matošić" <(E-Mail Removed)> wrote in message
> news:<cohjk5$j9p$(E-Mail Removed)>...
>> I wont to change the text (something) colour in a td tag.
>>
>> <table> <tr><td>something</td></tr></table>
>> I have a form which validates and i wont to (if the field is incorrect)
>> change the txt colour in front
>> of the txt field . I dont know how to reach the text from javascript?

>
> Well...for starters, it's not a 'tag' - not once it shows up on the
> screen. By then it's an object, and you can 'get' it for programming
> by several methods; probably the easiest is to simply id it, and use:
>
> document.getElementById('cell id') //no spaces!
>
> ...and then change its style.color property to what you'd like.
>
> document.getElementById('somecell').style.color = '#f00';



 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      12-01-2004
On Wed, 1 Dec 2004 10:25:45 +0100, Filip Matosic <(E-Mail Removed)> wrote:

> THX works fine, but i thought it was a tag, aren't all html elements
> tags (TD, TABLE, TR .....).


If you want to be pedantic, no. See
<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2> for a complete
description of the various mark-up components.

> Do you mean that as an object its an instance of the table?


Something like that. I think the emphasis was on the object model: once a
document has been parsed, its content is represented as a tree of objects
- elements, text nodes, etc.

In my opinion, the correct way to refer to something like TD is the "TD
(or table cell) element", unless you're referring to something more
specific, like the start tag of that element.

[snip]

Mike


Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
To vlan tag or not to tag? budyerr Cisco 1 07-08-2004 03:45 AM
using param or out tag inside sql tag (jsp/jstl/tomcat) shahbaz Java 0 10-27-2003 02:46 AM
struts tag inside a tag kishan bisht Java 1 07-08-2003 11:04 PM
How to embed the <jsp:plugin> tag into a tag handler class...HELP !! jstack Java 1 07-04-2003 06:58 PM



Advertisments