question about pop-up menu

Discussion in 'JavaScript' started by progfrog, Jan 18, 2008.

  1. #1
    HI everyone
    My question is like that
    this is the code:

    <script language="javascript">
    function showHideTable(menuId){
    var obj=document.getElementById(menuId)
    obj.style.visibility=(obj.style.visibility=="visible"?"hidden":"visible")
    }
    </script>

    I need three things:
    1 can someone put this code into reguler if/else and make it more simple for me?
    2 what is this syntax with "? :" means?
    3 why do i need this function to a pop-up menu?



    looking fror hearing from all of u guys
    :)
    progfrog
     
    progfrog, Jan 18, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    I'll answer question 1 & 2 for you.

    
    <script language="javascript">
    function showHideTable(menuId){
        var obj=document.getElementById(menuId)
        if (obj.style.visibility == "visible"){
            obj.style.visibility = "hidden";
        } else {
            obj.style.visibility = "visible";
        }
    }
    </script> 
    
    Code (markup):
    That's your function re-written for IF/ELSE.

    
    (obj.style.visibility=="visible"?"hidden":"visible")
    
    Code (markup):
    Means set if obj.style.visibility is visible, return hidden, otherwise return visible.

    Sorry if that's bit confusing. It means exactly what the IF/ELSE statement does above.

    Jay
     
    jayshah, Jan 19, 2008 IP