...

View Full Version : Using getElementBiId to change the text on a button to bold



Dieter Rausch
01-08-2004, 05:11 PM
Hi Everyone,

I am using the following code in a function to change the background and the text color of a button:

function indicateShortTrade() {
document.getElementById("btShort").style.backgroundColor="#FF0000";
document.getElementById("btShort").style.color="#FFFFFF";
window.focus()
}

The problem is that I am also trying to change the font to bold.
None of the properties I tried - or shall I say invented - worked. I tried ("btShort").fontweight="bold"; "btShort").style.text="bold" and various others, but the text stays normal.

If you know the correct code please let me know. And..., I nearly forgot, how to change back from "bold" to "normal" again.

Thanks,
Dieter

fredmv
01-08-2004, 05:14 PM
It's style.fontWeight...

Also, http://www.codingforums.com/showthread.php?s=&threadid=17515.

Dieter Rausch
01-08-2004, 06:51 PM
Thanks Fred,

I can't believe it. The "W" vs "w" in fontWeight makes all the difference. Just as a test I changed "backgroundColor" to "backgroundcolor" and found that it would not work. I guess this proves that JS is case sensitive. Problem solved.:thumbsup: Thanks.

Skyzyx
01-08-2004, 07:02 PM
This was posted in the wrong forum. I believe that according to the rules for this forum, it should be deleted.

jkd
01-08-2004, 08:46 PM
Originally posted by Skyzyx
This was posted in the wrong forum. I believe that according to the rules for this forum, it should be deleted.

I'll just move it instead... :D

Dieter Rausch
01-08-2004, 10:14 PM
Thanks jkd,

When I realised my mistake it was already too late. My next post is in the correct section.

Dieter

:o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum