Results 1 to 5 of 5

Thread: Javascript functions

  1. #1
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Javascript functions

    As in my last post, remember the fact that I'm fairly new to JS but do have a lot of knowledge of Flash ActionScript.

    So on to my question.

    I am trying to make a function out of a JS script that I've been using a lot but cannot get this to work. I'm hoping that it's an easy syntax fix. I've tried everything.

    In an external JS file that I DO have attached to my html doc, I have the code:
    function open(openid) {
    if(document.getElementById(openid).style.visibility=='hidden') {
    document.getElementById(openid).style.visibility='visible'
    } else {
    document.getElementById(openid).style.visibility='hidden'
    }
    }

    And in my html code I have:
    onclick="open('import')" where 'import' is the ID I gave to a table.

    This worked fine when it was all internal, like this:
    onclick="if(document.getElementById('import').style.visibility=='hidden') {document.getElementById('import').style.visibility='visible';} else {document.getElementById('import).style.visibility='hidden';}"

    If I can't get it to work then I guess I'll just go back to having to have a lot of code. I just wanted to clean things up a bit.

    Thanks!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try changing the function name to openDiv or something other than open. See if that fixes it.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ha!!!! You rock Bro!! Thanks a ton

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Not a problem, let us know if you need any more help.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Jan 2007
    Location
    Charlotte, NC
    Posts
    82
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Well I'm having a real problem with swapping images. Refer to this post...

    http://www.dynamicdrive.com/forums/s...ad.php?t=16703

    Thanks again!

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
  •