1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Javascript help

Discussion in 'Software' started by Stompy, 21 Mar 2010.

  1. Stompy

    Stompy What's a Dremel?

    Joined:
    16 Aug 2004
    Posts:
    1,112
    Likes Received:
    3
    Probably me being blind and missing something obvious, but I just can't get this function to work.
    It's supposed to show or hide elements, or change their opacity depending on the variables given to it.

    Code:
    //Shows or hides elements
    function display(elementid,show,fade,opacity)
    {
    	switch(show)
    	{
    		case 1:
    			if(fade=1)
    			{
    				document.getElementById(elementid).style.display = "inline";								
    				
    				//Standard
    				document.getElementById(elementid).style.opacity = opacity / 100;
    				
    				//IE Legacy                  
    				document.getElementById(elementid).style.filter  = "alpha(opacity="+opacity+")"; 
    			}
    			else
    			{
    				document.getElementById(elementid).style.display = "inline";
    			}
    			break;
    		
    		case 0:
    			{
    				document.getElementById(elementid).style.display = "none";
    			}
    			break;
    	}				
    }
    So for example if I run the function
    Code:
    display('foo',1,1,40);
    It should change the element
    Code:
    <span id="foo">bar</span>
    To 40% opacity. Except..... it doesn't.

    Any ideas? :)
     
  2. Stompy

    Stompy What's a Dremel?

    Joined:
    16 Aug 2004
    Posts:
    1,112
    Likes Received:
    3
    No one?!
     
  3. ch424

    ch424 Design Warrior

    Joined:
    26 May 2004
    Posts:
    3,112
    Likes Received:
    41
    works fine here...

    The problem might actually be the way you're including the script in the page. Post some of the HTML as well?
     

Share This Page