Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    bold fonts in javascript?

    how can i change my fonts in javascript ??

    i found tis following thumbnail javascript:

    <script type="text/javascript"><!--

    //thumbnail script
    thumb=new Image();
    thumb2=new Image();
    thumb3=new Image();

    thumb.src ="art.jpg"
    thumb2.src="gypsies.jpg"
    thumb3.src="skein.jpg"


    document.getElementById("T1").src=thumb.src;
    document.getElementById("T2").src=thumb2.src;
    document.getElementById("T3").src=thumb3.src;


    function thumbtobig(thumbs){
    if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="title1 descriptionssssss";}
    //i want to bold the title but leave the descriptions as normal


    else if(thumbs==2){document.getElementById("large").src=thumb2.src;ins_text="title2 descriptionssssss";}
    //i want to bold the title but leave the descriptions as normal



    else if(thumbs==3){document.getElementById("large").src=thumb3.src;ins_text="title3 descriptionssssss";}
    //i want to bold the title but leave the descriptions as normal



    document.getElementById("caption").replaceChild(document.createTextNode(ins_text), document.getElementById("caption").firstChild);

    return false;}

    //--></script>

    can any experts out there pls help out..

    thanks in advance!!
    Last edited by jinger; 10-14-2003 at 10:07 AM.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try insert normal HTML tags in string

    if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="<b>title1 descriptionssssss</b>";}
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm... i tried inserting the normal HTML tags in string

    ins_text="<b>title1 descriptionssssss</b>";}

    but the outcome would be like
    "<b>title1 descriptionssssss</b>"

    the tags are shown together with the descriptions.
    Are there anymore of ur precious solutions?

    thanks!

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This looks familar:

    title1 descriptionssssss

  • #5
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes

    if its familar, den can someone pls help or there are any good tutorials to recommend? abt tis topic..

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try:

    if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="'<b>'+title1 descriptionssssss+'</b>'";}

    ....Willy

  • #7
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Willy Duitt
    Try:

    if(thumbs==1){document.getElementById("large").src=thumb.src;ins_text="'<b>'+title1 descriptionssssss+'</b>'";}

    ....Willy
    it also share the same results as the pervious one...

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try using styles on-the-fly:

    Code:
    if(thumbs==1){
    document.getElementById("large").src=thumb.src;
    document.getElementById("large").style.fontWeight="bold";
    ins_text="+title1 descriptionssssss+";
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #9
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    err..
    it still doesnt work.. my code is originated from the following attachment~

    does it mean tat i can only use normal default plain text?
    Attached Files Attached Files
    Last edited by jinger; 10-15-2003 at 10:09 AM.

  • #10
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is there by any chance tat i can use array for this script?

    like that:

    var messages=new Array()
    messages[0]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

    messages[1]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

    messages[2]="<font size='1' face='Verdana'><a href='http:///'><b>title</b></br>all the descriptions</a></font>"

    juz a wild guess...

  • #11
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Untested


    <script type="text/javascript">
    function thumbtobig(thumbs){

    var messages=new Array()

    if(thumbs==0){
    messages[messages.length] = new Array("art.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
    document.getElementById("T1").src=messages[0];
    document.getElementById("ins_text").innerHTML=messages[1];
    }

    else if(thumbs==1){
    messages[messages.length] = new Array("gypsies.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
    document.getElementById("T2").src=messages[0];
    document.getElementById("ins_text").innerHTML=messages[1];
    }

    else if(thumbs==2){
    messages[messages.length] = new Array("skein.jpg","<font size='1' face='Verdana'><b>title</b></br>all the descriptions</font>");
    document.getElementById("T3").src=messages[0];
    document.getElementById("ins_text").innerHTML=messages[1];
    }
    }
    Last edited by Willy Duitt; 10-16-2003 at 12:47 AM.

  • #12
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply but, more errors came up....

    it says:

    'document.getElementById(...)' is null or not an object
    for the below codes...

    document.getElementById("T1").src=thumb1.src;
    document.getElementById("T2").src=thumb2.src;
    document.getElementById("T3").src=thumb3.src;
    document.getElementById("T4").src=thumb4.src;


  •  

    Posting Permissions

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