Results 1 to 2 of 2

Thread: put bold on Switch Content Script

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

    Default put bold on Switch Content Script

    1) Script Title: Switch Content Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tchcontent.htm

    3) Describe problem:

    How can I put bold on selected item? I want to put bold only at "curobj" selected... I try this code below, but it fails to reset non-current itens to normal after clicking...:

    Code:
    if (ccollect.length>0){
    curobj.style.fontWeight=(curobj.style.fontWeight!="bold")? "bold" : "normal";
    if (collapseprevious=="yes")
    contractcontent(cid)
    document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none";
    if (showstateobj.length>0){ //if "showstate" span exists in header
    if (collapseprevious=="no")
    showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
    else
    revivestatus()
    }
    }
    }

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, it would depend upon how you are using the script. If you have collapseprevious set to 'yes' and are not using the optional expand all and contract all links or the persistence feature, it would be rather easy -

    Put this function in the script:

    Code:
    function killBold(){
    var inc=0
    while (statecollect[inc]){
    statecollect[inc].parentNode.style.fontWeight='normal'
    inc++
    }
    }
    and use this instead of the line you had added:

    Code:
    if (ccollect.length>0){
    killBold();
    curobj.style.fontWeight=document.getElementById(cid).style.display!="block"? "bold" : "normal";
    if (collapseprevious=="yes")
    contractcontent(cid)
    document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
    if (showstateobj.length>0){ //if "showstate" span exists in header
    if (collapseprevious=="no")
    showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
    else
    revivestatus()
    }
    }
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •