.visibility changes when called from button -not function

Discussion in 'JavaScript' started by Vitus, Dec 23, 2007.

  1. #1
    This is the most interesting situation I have ever been presented with in my entire programming carrer. I have a function that executes if called from a button, not if it is called from other Javascript. the exact code is below.
    <head><script>
    var USERCS = "<%=session("user")%>"// USER Client Side = ASP Session User

    if (USERCS == "") { // If no user was set in ASP

    GrayOutBack("0") // Hide All Errors
    } else {

    GrayOutBack("1") // Show All Errors
    }

    function GrayOutBack(cond0){
    if (cond0=="1"){

    document.getElementById("BLACKOUT").style.visibility="visible";
    document.getElementById("ERR").style.visibility="visible";//presents error
    } else {

    document.getElementById("BLACKOUT").style.visibility="hidden";
    document.getElementById("ERR").style.visibility="hidden";
    }
    }


    Based on whether there is a user in the ASP session's User variable, the page will load an error. however, the error never appears when a user is logged in. However if you place alerts inside the GrayOutBack function, you'll see it will execute correctly, less the visibility lines.

    here's the real kicker though, if i put a button on the page with an onclick that points to GrayOutBack(0) or GrayOutBack(1) the script works perfectly, IE never reports any errors on the page after load, so i dont think i spelt anythign wrong on thoose two lines.

    Any help would be great
    ~Vitus
     
    Vitus, Dec 23, 2007 IP
  2. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    did you try to debug with firefox+firebug?
    I think you need to put a break point in GrayOutBack function and check if elements returned by getElementById calls are correct.
     
    locdev, Dec 24, 2007 IP