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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Posts
    128
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Two Java scripts not working

    Hello,

    I'm new to java script. I have placed two scripts into my HTML document and only one works. If I take one out, then the other works. What am I doing wrong? The page I'm talking about is mrswaldrop.com/temp2.htm

    Thanks for your help.

  • #2
    Regular Coder
    Join Date
    Oct 2010
    Posts
    128
    Thanks
    26
    Thanked 0 Times in 0 Posts
    OK, now it appears that neither is working. I swear it was working earlier

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,617 Times in 4,581 Posts
    No code, no help. There are a few mind readers who occasionally visit this forum, but they're at a conference on Rigel IV this week.
    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.

  • #4
    Regular Coder
    Join Date
    Oct 2010
    Posts
    128
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    No code, no help. There are a few mind readers who occasionally visit this forum, but they're at a conference on Rigel IV this week.
    That's why I posted a link.

    Here's the code.
    <!-- include jQuery library -->
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <!-- include Cycle plugin -->
    <script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    $('.slideshow').cycle({
    fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
    });
    </script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script><script src="temp.js" type="text/javascript"></script>

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,617 Times in 4,581 Posts
    LOL! Well, I'm old and going senile. And now blind as well. You didn't make it *INTO* a link, so I didn't notice that there was a URL in there. DOH on me.

    I don't use jQuery, but I'll take a peek, anyway.
    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
    Regular Coder
    Join Date
    Oct 2010
    Posts
    128
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    LOL! Well, I'm old and going senile. And now blind as well. You didn't make it *INTO* a link, so I didn't notice that there was a URL in there. DOH on me.

    I don't use jQuery, but I'll take a peek, anyway.
    No problem, I should have linked it. Besides, I meant to put the winking smilie to let you know I was joking around.

    Anyway, thanks for taking a peak.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,617 Times in 4,581 Posts
    Bring it up in Firefox. Enable Firebug debugging. Hit refresh.

    WHAM.

    Error: $(".slideshow").cycle is not a function

    Since pretty clearly there is a cycle() function in that JS code, I'd have to guess that the problem is that $(".slideshow") isn't selecting an element or is maybe selecting more than one element.
    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.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,617 Times in 4,581 Posts
    Well, so much for that theory. I see the <div class="slideshow"> and there's only one of them.

    I noticed that cycle( ) was defined as $.fn.cycle so maybe there is indeed a conflict in the definition of fn. Anyway, sorry, not a jQuery user, as I said.
    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.

  • #9
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    891
    Thanks
    174
    Thanked 102 Times in 102 Posts
    Hi

    I'm no Jquery person but I think you are ref a class instead of an ID

    "The plugin provides a method called cycle which is invoked on a container element. Each child element of the container becomes a "slide". Options control how and when the slides are transitioned."

    I think is wrong
    Code:
    $('.slideshow').cycle
    I think it sould ref ID
    Code:
    example only
    $('#s1').cycle('fade')
    for ref:
    http://malsup.com/jquery/cycle/begin.html

    http://malsup.com/jquery/cycle/

    also I think you have this twice
    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript">
    I would get rid of the second one
    LT
    Last edited by low tech; 10-28-2010 at 04:51 AM.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,617 Times in 4,581 Posts
    No, that much of jQuery I know.

    You can refer to elements *EITHER* by class name or by id.

    The "." prefix means class name, the "#" prefix means id. Same as in CSS.

    Now, you *can* get in trouble using class name. If you use a $(".xxx") selector and you have more than one object of the classname, jQuery will try to apply the property/method/whatever to *all* those objects. And clearly there some functions where that's not going to work.

    But in this case, I see only a single object of that class, and so it should work.

    Personally, I would *NEVER* try to select a single object using class name, just because of the danger that you might accidentally be selecting more than one.

    But jQuery says its legal, even if inadvisable.
    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.

  • #11
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    891
    Thanks
    174
    Thanked 102 Times in 102 Posts
    Hi Old Pedant

    Thanks for putting me right:-)

    Yeh @ #7 I saw that you wrote "maybe selecting more than one element"

    so I thought he was using class name and so possibly it was causing problem --- when I ref the jquery site I saw they used an ID $('#s1') and I've used this same cycle plugin myself with an id and it worked fine. Hence my suggestion.

    Anyway I learned what the problem isn't:-)

    sorry to javanewbie7.
    LT


  •  

    Posting Permissions

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