Script Is Almost There

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scorpion53061

    Script Is Almost There

    I was really proud of myself. Having never worked with javascript before I
    took two scripts - one that did a slideshow but fit the image to the table
    and one that did not but provided a caption and I managed to get them
    together.

    Unfortauntely the "Previous" link returns an "undefined" error the second
    time through it. Does anyone have an idea what I might have done wrong??

    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <script>
    var NewImg = new Array(); // don't change this
    var Caption = new Array(); // don't change this

    NewImg[7] = 'pic1.jpeg';
    NewImg[2] = 'pic2.jpeg';
    NewImg[3] = 'pic3.jpeg';
    NewImg[4] = 'pic4.jpeg';
    NewImg[5] = 'pic5.jpeg';
    NewImg[6] = 'pic6.jpeg';
    NewImg[1] = 'pic7.jpeg';
    NewImg[8] = 'newlogo.jpg';

    // Specify the Captions...
    // To add more captions, just continue
    // the pattern, adding to the array below.
    // To use fewer captions, remove lines
    // starting at the end of the Caption array.
    // Caution: The number of Captions *must*
    // equal the number of NewImgs!

    Caption[1] = "Text for picture1.";
    Caption[2] = "Text for picture2.";
    Caption[3] = "Text for picture3.";
    Caption[4] = "Text for picture4.";
    Caption[5] = "Text for picture5.";
    Caption[6] = "Text for picture6.";
    Caption[7] = "Text for picture7.";
    Caption[8] = "Text for picture8.";
    var ImgNum = 0;
    var ImgLength = NewImg.length - 1;
    var ImgCap = Caption.length - 1;
    //Time delay between Slides in milliseconds
    var delay = 3000;
    var lock = false;
    var run;
    function chgImg(directio n) {
    if (document.image s) {
    ImgNum = ImgNum + direction;
    ImgCap = ImgCap + direction;
    if (ImgNum > ImgLength) {
    ImgNum = 1;
    }
    if (ImgNum < 0) {
    ImgNum = ImgLength;
    }
    document.slides how.src = NewImg[ImgNum];
    }
    if (document.getEl ementById)
    document.getEle mentById("Capti onBox").innerHT ML= Caption[ImgNum];

    }
    function auto() {
    if (lock == true) {
    lock = false;
    window.clearInt erval(run);
    }
    else if (lock == false) {
    lock = true;
    run = setInterval("ch gImg(1)", delay);
    }}
    // End -->
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>

    <body>
    <body onload='showHot =true;self.focu s();'">

    <table border="1" id="table1 " width="30%">
    <tr>
    <td id=CaptionBox class=Caption align=center colspan="3">
    Welcome to Sand Bay Beach Resorts!!<br>De signed By
    <a href="http://www.kjmsolution s.com ">KJM Solutions</a></td>
    </td>
    </tr>

    <td colspan="3"><!--webbot bot="HTMLMarkup " startspan --><img
    src="http://newlogo.jpg " name="slideshow "> //this line causes error on
    slideshow but //putting a space after the w and before the " seemed to make
    it go away. I know dumb idea right :)?
    <tr/>
    <td width="50 "><a href="javascrip t:chgImg(1) ">Next</a></td>

    <td width = "50 "><a href="javascrip t:chgImg(-1) ">Previous</a></td>

    <td width = "50 "><a href="javascrip t:auto() ">Auto/Stop</a></td>

    </tr>

    </table>
    <!--webbot bot="HTMLMarkup " endspan i-checksum="26346 " --></td>
    </tr>
    </table>

    <p>&nbsp;</p>

    </body>

    </html>


  • Jimmy Cerra

    #2
    Re: Script Is Almost There

    Welcome to the wild world of JavaScript, Scorpion 53061!
    [color=blue]
    > NewImg[7] = 'pic1.jpeg';
    > NewImg[2] = 'pic2.jpeg';
    > NewImg[3] = 'pic3.jpeg';
    > NewImg[4] = 'pic4.jpeg';
    > NewImg[5] = 'pic5.jpeg';
    > NewImg[6] = 'pic6.jpeg';
    > NewImg[1] = 'pic7.jpeg';
    > NewImg[8] = 'newlogo.jpg';[/color]

    Did you know that this can be replaced by:

    NewImg = [
    'pic7.jpeg',
    'pic2.jpeg',
    'pic3.jpeg',
    'pic4.jpeg',
    'pic5.jpeg',
    'pic6.jpeg',
    'pic1.jpeg',
    'newlogo.jpg'
    ];

    Saves some typing (and precious bandwidth).
    [color=blue]
    > Unfortauntely the "Previous" link returns an "undefined" error the second
    > time through it. Does anyone have an idea what I might have done wrong??[/color]

    I'll leave the debugging to others; however, I will point out that
    your HTML is invalid. Fix it, then put your script into an external
    file (for maximum efficiency).

    Here's a hint, though. You probably have a "race condition" causing
    the error. Type wrapping everything into a function, and call it
    during the onload event.

    Hope that's useful,

    --
    Jimmy Cerra

    Comment

    • scorpion53061

      #3
      Re: Script Is Almost There

      Thanks Jimmy...

      This page is at



      Everything is working perfectly now except that the bottom "include page"
      (called "bottom.htm ") disappeared after applying the script although it is
      visible in Frontpage.

      Can you or anyone help please....
      "Jimmy Cerra" <jimbomaps@hotm ail.com> wrote in message
      news:9462edc9.0 407142335.7e0b9 be3@posting.goo gle.com...[color=blue]
      > Welcome to the wild world of JavaScript, Scorpion 53061!
      >[color=green]
      > > NewImg[7] = 'pic1.jpeg';
      > > NewImg[2] = 'pic2.jpeg';
      > > NewImg[3] = 'pic3.jpeg';
      > > NewImg[4] = 'pic4.jpeg';
      > > NewImg[5] = 'pic5.jpeg';
      > > NewImg[6] = 'pic6.jpeg';
      > > NewImg[1] = 'pic7.jpeg';
      > > NewImg[8] = 'newlogo.jpg';[/color]
      >
      > Did you know that this can be replaced by:
      >
      > NewImg = [
      > 'pic7.jpeg',
      > 'pic2.jpeg',
      > 'pic3.jpeg',
      > 'pic4.jpeg',
      > 'pic5.jpeg',
      > 'pic6.jpeg',
      > 'pic1.jpeg',
      > 'newlogo.jpg'
      > ];
      >
      > Saves some typing (and precious bandwidth).
      >[color=green]
      > > Unfortauntely the "Previous" link returns an "undefined" error the[/color][/color]
      second[color=blue][color=green]
      > > time through it. Does anyone have an idea what I might have done wrong??[/color]
      >
      > I'll leave the debugging to others; however, I will point out that
      > your HTML is invalid. Fix it, then put your script into an external
      > file (for maximum efficiency).
      >
      > Here's a hint, though. You probably have a "race condition" causing
      > the error. Type wrapping everything into a function, and call it
      > during the onload event.
      >
      > Hope that's useful,
      >
      > --
      > Jimmy Cerra[/color]


      Comment

      • scorpion53061

        #4
        Re: Script Is Almost There

        Problem solved thanks Jimmy.


        "Jimmy Cerra" <jimbomaps@hotm ail.com> wrote in message
        news:9462edc9.0 407142335.7e0b9 be3@posting.goo gle.com...[color=blue]
        > Welcome to the wild world of JavaScript, Scorpion 53061!
        >[color=green]
        > > NewImg[7] = 'pic1.jpeg';
        > > NewImg[2] = 'pic2.jpeg';
        > > NewImg[3] = 'pic3.jpeg';
        > > NewImg[4] = 'pic4.jpeg';
        > > NewImg[5] = 'pic5.jpeg';
        > > NewImg[6] = 'pic6.jpeg';
        > > NewImg[1] = 'pic7.jpeg';
        > > NewImg[8] = 'newlogo.jpg';[/color]
        >
        > Did you know that this can be replaced by:
        >
        > NewImg = [
        > 'pic7.jpeg',
        > 'pic2.jpeg',
        > 'pic3.jpeg',
        > 'pic4.jpeg',
        > 'pic5.jpeg',
        > 'pic6.jpeg',
        > 'pic1.jpeg',
        > 'newlogo.jpg'
        > ];
        >
        > Saves some typing (and precious bandwidth).
        >[color=green]
        > > Unfortauntely the "Previous" link returns an "undefined" error the[/color][/color]
        second[color=blue][color=green]
        > > time through it. Does anyone have an idea what I might have done wrong??[/color]
        >
        > I'll leave the debugging to others; however, I will point out that
        > your HTML is invalid. Fix it, then put your script into an external
        > file (for maximum efficiency).
        >
        > Here's a hint, though. You probably have a "race condition" causing
        > the error. Type wrapping everything into a function, and call it
        > during the onload event.
        >
        > Hope that's useful,
        >
        > --
        > Jimmy Cerra[/color]


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Script Is Almost There

          scorpion53061 wrote:[color=blue]
          > This page is at
          >
          > http://www.sandbaybeachresort.com/as...dardsuites.asp
          >
          > Everything is working perfectly now [...][/color]

          No, see
          <http://validator.w3.or g/check?uri=http://www.sandbaybeac hresort.com/aspnet_client/sandbaybeach/standardsuites. asp&ss=1;verbos e=1>

          If I change the encoding to ISO-8859-1 so that the document can be
          validated, the Validator shows a bunch of errors you have *not* fixed.
          [color=blue]
          > [...][/color]

          And if you would have not top-posted as strongly recommended in the
          FAQ, you would have probably known: <http://jibbering.com/faq/#FAQ2_3>


          PointedEars

          Comment

          • scorpion53061

            #6
            Re: Script Is Almost There

            Thanks Thomas what exact purpose does your posting serve other than to tear
            those down around you. I stated I was new at this. I suppose you were born
            with all the wisdom that javascript has to give right?

            And I will post any way I want thank you very much.
            "Thomas 'PointedEars' Lahn" <PointedEars@nu rfuerspam.de> wrote in message
            news:40F9C3B9.9 080308@PointedE ars.de...[color=blue]
            > scorpion53061 wrote:[color=green]
            > > This page is at
            > >
            > >[/color][/color]
            http://www.sandbaybeachresort.com/as...dardsuites.asp[color=blue][color=green]
            > >
            > > Everything is working perfectly now [...][/color]
            >
            > No, see
            >[/color]
            <http://validator.w3.org/check?uri=ht...rt.com/aspnet_
            client/sandbaybeach/standardsuites. asp&ss=1;verbos e=1>[color=blue]
            >
            > If I change the encoding to ISO-8859-1 so that the document can be
            > validated, the Validator shows a bunch of errors you have *not* fixed.
            >[color=green]
            > > [...][/color]
            >
            > And if you would have not top-posted as strongly recommended in the
            > FAQ, you would have probably known: <http://jibbering.com/faq/#FAQ2_3>
            >
            >
            > PointedEars[/color]


            Comment

            • Andrew Thompson

              #7
              Re: Script Is Almost There

              On Mon, 19 Jul 2004 22:39:11 -0500, scorpion53061 wrote:
              [color=blue]
              > Thanks Thomas what exact purpose does your posting serve other than to tear
              > those down around you.[/color]

              Thomas made good points. You cannot expect JS
              to work as you expect if the underlying HTML
              structure is broken.

              Fix the HTML first, ensure the (any) CSS
              is valid, *then* look at the JS.

              And in relation to the 'top-post' comment.

              It can be rather frustrating if long, detailed
              answers are provided (does not really apply here)
              yet it becomes apparent the OP only read the
              first few lines of the response.

              My advice to you. Do not be sensitive or precious.

              You can gain quite a lot from these forums if you
              can learn to tolerate a bit of 'rough and tumble'.
              Whereas if you're a sensitive type, you tend not
              to see through the criticism (perceived or actual)
              to the golden nugget of advice at the center.

              --
              Andrew Thompson
              http://www.PhySci.org/ Open-source software suite
              http://www.PhySci.org/codes/ Web & IT Help
              http://www.1point1C.org/ Science & Technology

              Comment

              • scorpion53061

                #8
                Re: Script Is Almost There

                I am just in a bad mood.

                And that didnt help.

                I said in my post I was new at this. I am trying, and it is frustrating at
                times.

                Thanks for your thoughts.

                "Andrew Thompson" <SeeMySites@www .invalid> wrote in message
                news:if2pm2aahf av$.1gzmrfa8m34 oh.dlg@40tude.n et...[color=blue]
                > On Mon, 19 Jul 2004 22:39:11 -0500, scorpion53061 wrote:
                >[color=green]
                > > Thanks Thomas what exact purpose does your posting serve other than to[/color][/color]
                tear[color=blue][color=green]
                > > those down around you.[/color]
                >
                > Thomas made good points. You cannot expect JS
                > to work as you expect if the underlying HTML
                > structure is broken.
                >
                > Fix the HTML first, ensure the (any) CSS
                > is valid, *then* look at the JS.
                >
                > And in relation to the 'top-post' comment.
                >
                > It can be rather frustrating if long, detailed
                > answers are provided (does not really apply here)
                > yet it becomes apparent the OP only read the
                > first few lines of the response.
                >
                > My advice to you. Do not be sensitive or precious.
                >
                > You can gain quite a lot from these forums if you
                > can learn to tolerate a bit of 'rough and tumble'.
                > Whereas if you're a sensitive type, you tend not
                > to see through the criticism (perceived or actual)
                > to the golden nugget of advice at the center.
                >
                > --
                > Andrew Thompson
                > http://www.PhySci.org/ Open-source software suite
                > http://www.PhySci.org/codes/ Web & IT Help
                > http://www.1point1C.org/ Science & Technology[/color]


                Comment

                Working...