Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Effect Opening and Closing a Div

    Hi there all,

    Trying to adapt a bit of Code, but failing wonderfully!

    I'm writing in Cold Fusion, but using a little java script to create the sliding effect. It's from a sliding open list function in another site, and I tried to just hack my current needs in there.

    Code:
    <script>
    	function DC_ShowHideMoreWebsites(id) {
    		if( document.getElementById( "contentsections2").style.display=="none" ) {
    			Effect.BlindDown( "contentsections2"); 
    			 return false;
    		} else {
    			Effect.SlideUp( "contentsections2" );  return false;
    		}
    	}
    	</script>
    is followed by

    Code:
    <p id="moreScreenshots"><a href="#" onclick="DC_ShowHideMoreWebsites"; return false;">More Website Examples</a></p>
    I've tested the script, div and the DB call by just calling it with
    Code:
    <p id="moreScreenshots"><a href="#" onclick="Effect.BlindDown('contentsections2'); return false;">More Website Examples</a></p>
    And that works fine.

    I've never coded in Java, hence the problem! any help appreciated
    Last edited by mercuryfrost; 07-20-2010 at 03:45 PM.

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    St George, UT
    Posts
    138
    Thanks
    6
    Thanked 17 Times in 17 Posts
    Are you getting any errors in Firefox's Error Console?

  • #3
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't appear to be no.

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    It will be a whole lot easier to get to the bottom of this if we can see your test page. Do you have this up anywhere we can get to it?
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,652
    Thanks
    80
    Thanked 4,640 Times in 4,602 Posts
    Makes no sense:
    Code:
    <p id="moreScreenshots"><a href="#" onclick="DC_ShowHideMoreWebsites"; return false;">More Website
    (1) You have mismatched quote marks. Quotes *MUST* come in pairs.
    (2) You are *NOT* calling a function. There are no parentheses after the function name there.

    You declared the function as
    Code:
    function DC_ShowHideMoreWebsites(id) { ... }
    meaning that you expect to be passed an id value when the function is invoked.

    Yet the code in that function never uses the id at all, so why is it there?

    So:
    Code:
    function DC_ShowHideMoreWebsites( ) /* no arguments needed */
    {
        ... your code ...
    }
    And then
    Code:
    <p id="moreScreenshots"><a href="#" onclick="DC_ShowHideMoreWebsites(); return false;">More Website Examples</a></p>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Many thanks for the advice all
    Have it working now after spotting a few little errors


    It was calling an id because the code I took it from had been on a loop.

    There was the stray quote marks you told of.
    The semi-colon was outside the quotes before the return false

    After this the script was working, but jumping to the top of the page. So changed the href to javascript:;

    Final code was as follows, and works like a dream, thanks for time all!
    Code:
    <script>
    	function DC_ShowHideMoreWebsites( ) {
    		if( document.getElementById( "contentsections2").style.display=="none" ) {
    			Effect.BlindDown( "contentsections2"); 
    			 return false;
    		} else {
    			Effect.SlideUp( "contentsections2" );  return false;
    		}
    	}
    	</script>
    Code:
    <p id="moreScreenshots"><a href="javascript:;" onclick="DC_ShowHideMoreWebsites()" return false;>More Website Examples</a></p>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •