SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    definitionproblem

    Extract from eskvalleyenergy.org/hptest.htm:
    <form name="SlideShow">

    Extract from eskvalleyenergy.org/pt2.js
    f = document.getElementsByName(SlideShow);

    Why do I get "SlideShow is not defined"? I think it's because the javascript runs before the html. How do I avoid this?

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because you've omitted the quotation marks. Unless you have a variable named SlideShow, the second extract will fail.

    It should be,
    Code:
    f = document.getElementsByName("SlideShow");
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    defininitionproblem

    ok thanks. Can't see the wood for the trees sometimes. Now: Why does

    f.delay.value = display; give f.delay has no properties
    and
    f.currSlide.value give f.currSlide has no properties. ?
    (same files as before)

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably because the Node object doesn't have any properties with those names.

    You could use f.elements['delay'].value etc., if you're trying to refer to fields within the form.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    definitionproblem

    That gives f.elements has no properties

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah … the getElementsByName() returns a collection of elements. So you have to use f[0].elements['delay'].value.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting there

    That just gave f[0] has no properties. Got round those problems. All works now but for this function(and others like it) function runSS(n){
    n++;
    if(n >= SLIDES.length){
    n = 0;
    }
    document.images["stage"].src = S[n].src;
    if(document.all && navigator.userAgent.indexOf("Opera") < 0 && navigator.userAgent.indexOf("Windows") >= 0){
    document.images["stage"].style.visibility = "hidden";
    document.images["stage"].filters.item(0).apply();
    document.images["stage"].filters.item(0).transition = effect;
    document.images["stage"].style.visibility = "visible";
    document.images["stage"].filters(0).play(duration);
    }
    currSlide.value = n;
    // f.wichIm[n].selected = true;
    t = setTimeout("runSS(" + currSlide.value + ")", f.delay.value * 1000) }; Which doesn't work coz it says n is NaN. ??????????


Bookmarks

Posting Permissions

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