Results 1 to 8 of 8

Thread: How to make the font bold?

  1. #1
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to make the font bold?

    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>

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    here:

    Code:
    <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>

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Or.. Use a class name and define it there:

    Code:
    <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>
    - Mike

  4. #4
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that would be more convinient.

  5. #5
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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"?

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    If you used my script, add this..
    Code:
    <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
    - Mike

  7. #7
    Join Date
    Aug 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thanks a lot

    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.

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mburt
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •