Log in

View Full Version : How to make the font bold?



terkini
08-17-2006, 10:25 AM
Hi guys, I am new here and this is my first posting.
I have the javascript below which display a statement every hour. My problem is that I cannot make the font of the statements bold or italic. Can anybody teach me how to make the fonts bold and italic. Thank you.:)

<SCRIPT LANGUAGE="JavaScript">
<!--

var ar = new Array(".",
".",
".",
".",
".",
".",
".",
".",
"It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.",
"It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.",
"You control your attitude. If you are negative, it is because you have decided to be negative and not because of other people or circumstances.",
"Act as if you have a good attitude. Remember actions triggers feelings just like feelings trigger actions.",
"Before a person can achieve the kind of results he wants, he must first become that person. He must then think, walk, talk, act and conduct himself in all of his affairs, as would the person he wishes to become.",
"Treat everybody as the most important person in the world.",
"Attitudes are based on assumptions. In order to change attitudes, one must first change one's assumptions.",
"Develop the attitude that there are more reasons why you should succeed than reasons why you should fail.",
"When you are faced with a problem, adopt the attitude that you can and will solve it.",
"We become what we think about. Control your thoughts and you will control your life.",
"Radiate the attitude of confidence, of well being, of a person who knows what he is doing. You will then find good things happening to you right away.",
"It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.",
"It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.",
".",
".",
".");

var now = new Date();
var num = now.getHours();
num %= ar.length;
document.write(ar[num]);

// -->
</SCRIPT>

shachi
08-17-2006, 11:30 AM
here:



<SCRIPT LANGUAGE="JavaScript">
<!--

var ar = new Array(".",
".",
".",
".",
".",
".",
".",
".",
"<b>It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.</b>",
"<b>It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.</b>",
"<b>You control your attitude. If you are negative, it is because you have decided to be negative and not because of other people or circumstances.</b>",
"<b>Act as if you have a good attitude. Remember actions triggers feelings just like feelings trigger actions.</b>",
"<b>Before a person can achieve the kind of results he wants, he must first become that person. He must then think, walk, talk, act and conduct himself in all of his affairs, as would the person he wishes to become.</b>",
"<b>Treat everybody as the most important person in the world.</b>",
"<b>Attitudes are based on assumptions. In order to change attitudes, one must first change one's assumptions.</b>",
"<b>Develop the attitude that there are more reasons why you should succeed than reasons why you should fail.</b>",
"<b>When you are faced with a problem, adopt the attitude that you can and will solve it.</b>",
"<b>We become what we think about. Control your thoughts and you will control your life.</b>",
"<b>Radiate the attitude of confidence, of well being, of a person who knows what he is doing. You will then find good things happening to you right away.",
"<b>It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.</b>",
"<b>It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.</b>",
".",
".",
".");

var now = new Date();
var num = now.getHours();
num %= ar.length;
document.write(ar[num]);

// -->
</SCRIPT>


to make the text italic change the <b></b> to <i></i>

mburt
08-17-2006, 01:46 PM
Or.. Use a class name and define it there:



<SCRIPT LANGUAGE="JavaScript">
<!--

var ar = new Array(".",
".",
".",
".",
".",
".",
".",
".",
"It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.",
"It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.",
"You control your attitude. If you are negative, it is because you have decided to be negative and not because of other people or circumstances.",
"Act as if you have a good attitude. Remember actions triggers feelings just like feelings trigger actions.",
"Before a person can achieve the kind of results he wants, he must first become that person. He must then think, walk, talk, act and conduct himself in all of his affairs, as would the person he wishes to become.",
"Treat everybody as the most important person in the world.",
"Attitudes are based on assumptions. In order to change attitudes, one must first change one's assumptions.",
"Develop the attitude that there are more reasons why you should succeed than reasons why you should fail.",
"When you are faced with a problem, adopt the attitude that you can and will solve it.",
"We become what we think about. Control your thoughts and you will control your life.",
"Radiate the attitude of confidence, of well being, of a person who knows what he is doing. You will then find good things happening to you right away.",
"It is your attitude at the beginning of a task more than anything else, that will determine our success or failure.",
"It is our attitude toward life that will determine life's attitude towards you. Despite many people's belief to the contrary, life pays no favourites.",
".",
".",
".");

var now = new Date();
var num = now.getHours();
num %= ar.length;
document.write("<div class='test'>" + ar[num] + "</div>");

// -->
</SCRIPT>

<style type="text/css">
.test {
font-weight:bold;
font-style:italic
}
</style>

shachi
08-17-2006, 02:23 PM
that would be more convinient.

terkini
08-18-2006, 02:16 AM
Shachi and mburt, you guys are great and really helpful. You guys immediately solved the problem that took me the whole night trying to solve it. Thanks guys...thanks a lot.
btw, how do i change the type of the font? at the moment the font is in Times Roman. what do i have to do if i want to change the font to "arial" or "verdana"?

mburt
08-18-2006, 02:52 AM
If you used my script, add this..


<style type="text/css">
.test {
font:12px verdana;
font-weight:bold;
font-style:italic
}
</style>


CSS is a great way to make things look better :)

terkini
08-20-2006, 03:28 PM
Dear mburt,
Thank you very much for the help. i am new to javascript, and with you guys help in this forum, i am more interested now to learn it. Keep it up guys, its people like you that make this forum great! Thanks.:)

mwinter
08-20-2006, 09:06 PM
font:12px verdana;

Except that pixel font sizes should be avoided, as should Verdana (at least if the desire is to reduce the font size when using it). When specifying font families, the appropriate generic family (sans-serif, in this case) should also be included.



font-weight:bold;
font-style:italic

Finally, if you're using the font shorthand properties, other font properties might as well be combined.

Mike