Help with validating my last two errors

Discussion in 'Water Cooler' started by ArnyVee, Sep 27, 2009.

  1. ArnyVee

    ArnyVee Regular Member

    Joined:
    May 25, 2009
    Messages:
    1,264
    Likes Received:
    39
    Hey folks,

    I need some help with a page that I had like 100 errors and I've brought it down to two final errors! :D

    So, here's what I have...


    .....it's referencing an image tag that I have within the code that isn't playing nice. I looked it up on Google and there were suggestions on putting the js script/code into an external file and then calling it to the page using something or other to fix the issue :)

    It's a javascript that I'm using and it's this one....

    Switch Content script

    .....so, how do I make this script into a js file and then 'call' it back to my page? Is there an easy tutorial that you've stumbled across out there?

    Here's the page in case anyone needed to see what I was doing: Walt Disney World Magic Kingdom Forum
     
  2. LissaE

    LissaE Newcomer

    Joined:
    Oct 7, 2009
    Messages:
    14
    Likes Received:
    0
    Location:
    Australia
    First Name:
    Lissa
    I'm coming a bit late on this, but I see you still have the issue lol

    To have the javascript called externally, you need to paste everything between the script tags (<script type="text/javascript"> and </script>)
    into a text file and save it as a .js file, call it whatever you want....then upload that file to a folder on your server.

    To call it, in the same place you previously had the javascript, place this code...making the necessary modifications for your filepath:

    <script type="text/javascript" src="url/to/javascript/file.js"></script>

    Hope that helps :)
     
  3. ArnyVee

    ArnyVee Regular Member

    Joined:
    May 25, 2009
    Messages:
    1,264
    Likes Received:
    39
    LissaE, thank you for the suggestion but it didn't work because the 'action' to expand and collapse along with the images are in the same bit of code. Here's the code....

    Code:
    <script type="text/javascript">
    // MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
    // Call Instance.init() at the very end. REQUIRED
    
    var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
    bobexample.setStatus('<img src="http://www.magicthemeparks.com/mk/forum/images/misc/delete.png" alt="" /> ', '<img src="http://www.magicthemeparks.com/mk/forum/images/misc/add.png" alt="" /> ')
    bobexample.setColor('purple', 'purple')
    bobexample.setPersist(true)
    bobexample.collapsePrevious(true) //Only one content open at any given time
    bobexample.init()
    </script>

    ....is there a way to 'call' only the bit of code with the images?
     
  4. Wayne Luke

    Wayne Luke Regular Member

    Joined:
    Apr 2, 2009
    Messages:
    991
    Likes Received:
    276
    Since you're using XHTML 1.0 transitional you probably have to surround your actual code with <![CDATA[ //]]> for it to validate.

    Code:
    <script type="text/javascript">
    <![CDATA[
    // MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
    // Call Instance.init() at the very end. REQUIRED
    
    var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
    bobexample.setStatus('<img src="http://www.magicthemeparks.com/mk/forum/images/misc/delete.png" alt="" /> ', '<img src="http://www.magicthemeparks.com/mk/forum/images/misc/add.png" alt="" /> ')
    bobexample.setColor('purple', 'purple')
    bobexample.setPersist(true)
    bobexample.collapsePrevious(true) //Only one content open at any given time
    bobexample.init()
    //]]>
    </script>
    
     
    2 people like this.
  5. LissaE

    LissaE Newcomer

    Joined:
    Oct 7, 2009
    Messages:
    14
    Likes Received:
    0
    Location:
    Australia
    First Name:
    Lissa
    OOoo I'll have to remember that one Wayne lol my javascript knowledge is pretty much limited to being able to paste the relevant bits in a js file and call it :D
     
  6. ArnyVee

    ArnyVee Regular Member

    Joined:
    May 25, 2009
    Messages:
    1,264
    Likes Received:
    39
    Wayne, it didn't work. When I added it, it's as if we disabled the ability to collapse the data and only sits on 'expand all' mode. And, there are no images showing (plus or minus images) on the page either. :(
     

Share This Page