howto randomise starting pic in slideshow?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David. E. Goble

    howto randomise starting pic in slideshow?

    I have a slideshow, it uses

    sigsImages=new Array()");

    sigsImages[0]="sigs/finished1.jpg"
    sigsImages[1]="sigs/foghorn.jpg"
    sigsImages[2]="sigs/motto.jpg"
    sigsImages[3]="sigs/sig.jpg"
    sigsImages[4]="sigs/SWAT.jpg"
    sigsImages[5]="sigs/title.gif"
    sigscounter=sig sImages.length-1"
    ....
    <td align="center"> <img id="sigsviewer " src="sigs/sig.jpg"></td>
    ....

    Instead of manually puting a file for the starting pic, how do I set
    it to a random pick?

    I tried;

    <td align="center"> <img id="sigsviewer " src=sigsImages[X]></td>

    but that don't work.


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Bow's and foggy's stored signatures</title>
    <SCRIPT src="sigsheader .js"></SCRIPT>
    </head>
    <body
    background="htt p://home.insightbb. com/clipart/backgrounds/bkgnd019.gif"
    bgcolor="#fffff f" link="#0000ff" text="#000000" vlink="#ff0000" >
    <h1 align="center"> Bow's and foggy's stored grahics</h1>
    <h2 align="center" style="color: rgb(255, 0, 0);" color="red">Tea m
    Special Forces</h2>
    <SCRIPT src="sigsbody.j s"></SCRIPT>
    <table align="center">
    <tr>
    <td>
    <a href="/cgi-bin/GBEntry?owner=e mailid">
    <img src="/global-images/guestbook/sign_gb.jpg" border="0"></a>
    </td>
    <td>
    <P>Then email it to us at <a
    href="mailto:Bo w.Foggy@insight bb.com">Bow.Fog gy@insightbb.co m</a></p>
    </td>
    <td>
    <a href="/cgi-bin/GBView?owner=em ailid">
    <img src="/global-images/guestbook/view_gb.jpg" border="0"></a>
    </td>
    </tr>
    </table>
    </body>
    </html>

    document.writel n("<script type=\"text/javascript\">") ;

    document.writel n("sigsImages=n ew Array()");

    document.writel n("sigsImages[0]=\"sigs/finished1.jpg\" ");
    document.writel n("sigsImages[1]=\"sigs/foghorn.jpg\"") ;
    document.writel n("sigsImages[2]=\"sigs/motto.jpg\"");
    document.writel n("sigsImages[3]=\"sigs/sig.jpg\"");
    document.writel n("sigsImages[4]=\"sigs/SWAT.jpg\"");
    document.writel n("sigsImages[5]=\"sigs/title.gif\"");

    document.writel n("sigscounter= sigsImages.leng th-1");
    document.writel n("sigsi=0");

    document.writel n("function sigsfirst()");
    document.writel n("{");
    document.writel n("document.get ElementById(\'s igsviewer\').sr c=sigsImages[0]");
    document.writel n("sigsi=0");
    document.writel n("}");

    document.writel n("function sigsprevious()" );
    document.writel n("{");
    document.writel n("if (sigsi>0)");
    document.writel n("{");
    document.writel n("sigsi--");
    document.writel n("document.get ElementById(\'s igsviewer\').sr c=sigsImages[sigsi]");
    document.writel n("}");
    document.writel n("}");

    document.writel n("function sigsnext()");
    document.writel n("{");
    document.writel n("if (sigsi<sigscoun ter)");
    document.writel n("{");
    document.writel n("sigsi++");
    document.writel n("document.get ElementById(\'s igsviewer\').sr c=sigsImages[sigsi]");
    document.writel n("}");
    document.writel n("}");

    document.writel n("function sigslast()");
    document.writel n("{");
    document.writel n("document.get ElementById(\'s igsviewer\').sr c=sigsImages[sigscounter]");
    document.writel n("}");
    document.writel n("<\/script>");


    document.writel n("<center>") ;
    document.writel n("<h1>sigs<\/h1>");
    document.writel n("<form>");
    document.writel n("<input value=\"First\" onclick=\"sigsf irst()\"
    type=\"button\" >");
    document.writel n("<input value=\"Previou s\" onclick=\"sigsp revious()\"
    type=\"button\" >");
    document.writel n("<input value=\"Next\" onclick=\"sigsn ext()\"
    type=\"button\" >");
    document.writel n("<input value=\"Last\" onclick=\"sigsl ast()\"
    type=\"button\" >");
    document.writel n("<\/form>");
    document.writel n("<table border=\"1\">") ;
    document.writel n("<tr>");
    document.writel n("<td align=\"center\ "><img id=\"sigsviewer \"
    src=\"sigs/sig.jpg\"><\/td>");
    document.writel n("<\/tr>");
    document.writel n("<\/table>");
    document.writel n("<p><\/p>");
    document.writel n("<form>");
    document.writel n("<input value=\"First\" onclick=\"sigsf irst()\"
    type=\"button\" >");
    document.writel n("<input value=\"Previou s\" onclick=\"sigsp revious()\"
    type=\"button\" >");
    document.writel n("<input value=\"Next\" onclick=\"sigsn ext()\"
    type=\"button\" >");
    document.writel n("<input value=\"Last\" onclick=\"sigsl ast()\"
    type=\"button\" >");
    document.writel n("<\/form>");
    document.writel n("<p><\/p>");
    document.writel n("<p>If you have a sig<\/p>");
    document.writel n("<\/center>");


    Regards David. E. Goble

    degoble[AT]pnc.com.au | dgoble[AT]pnc.com.au
    Po Box 648 (9 Murray St), Kingscote, Kangaroo Island SA 5223
  • Lachlan Hunt

    #2
    Re: howto randomise starting pic in slideshow?

    David. E. Goble wrote:[color=blue]
    > I have a slideshow, it uses
    > ...
    > Instead of manually puting a file for the starting pic, how do I set
    > it to a random pick?[/color]

    You have to use some kind of scripting, either on the server side or
    client side with JavaScript. In either case, ciwa.html is not an
    appropriate list. However, I will address your markup issues while your
    here.
    [color=blue]
    > <td align="center"> <img id="sigsviewer " src=sigsImages[X]></td>[/color]

    The align attribute is deprecated in favour of stylesheets. That same
    effect can be achieved using this simple line of CSS (perhaps with a
    slightly modified selctor, as appropriate)

    td { text-align: center; }
    [color=blue]
    > but that don't work.[/color]

    Of course the image doesn't do what you want because the src attribute
    accepts a URI, not an a JavaScript variable. You have to keep in mind
    that HTML, CSS and JavaScript are three totally seperate languages, and
    you really need to learn how they work together and how they don't.
    [color=blue]
    > <body
    > background="htt p://home.insightbb. com/clipart/backgrounds/bkgnd019.gif"
    > bgcolor="#fffff f" link="#0000ff" text="#000000" vlink="#ff0000" >[/color]

    Replace with CSS:

    body { background: white url(.../bkgnd019.gif); color: black; }
    :link { color: blue; }
    :visited { color: red; }
    [color=blue]
    > <h1 align="center"> Bow's and foggy's stored grahics</h1>[/color]

    h1 { text-align: center; }
    [color=blue]
    > <table align="center">[/color]

    table { margin-left: auto; margin-right: auto; }

    However, if this table is being used for layout purposes only, as it
    appears to be, I suggest you remove the table completely and replace
    with much leaner, semantic and valid code.
    [color=blue]
    > <a href="..."><img src="/global-images/guestbook/sign_gb.jpg" border="0"></a>[/color]

    the border attribute can be replaced by this CSS:

    a img { border: 0; }

    [color=blue]
    > ...
    > </body>
    > </html>[/color]

    What's all this crap you have after the end tag for the html element?
    Is this supposed to be in another file? You really should indicate such
    things more clearly.
    [color=blue]
    > document.writel n("<script type=\"text/javascript\">") ;[/color]

    How do you expect this to be treated as script when it is not within a
    script element itself? Any user agent should just treat this as text
    after the end of a document

    Are you aware that using document.write( ) is very bad practice, and you
    should be using the standardised DOM methods instead?

    [color=blue]
    > document.writel n("sigsImages=n ew Array()");[/color]

    What's the point of writing out each line of a script, using script? Do
    you really expect this script to be executed like that? I haven't
    checked, but I doubt it will.
    [color=blue]
    > document.writel n("<center>") ;[/color]

    Like I've suggested all the way through, don't use presentational
    elements and attributes when there are perfectly good CSS properties to
    use instead.

    Oh, and by the way, it might be worth while putting your markup through
    the validator before doing anything else.
    W3C's easy-to-use markup validation service, based on SGML and XML parsers.


    --
    Lachlan Hunt

    http://GetFirefox.com/ Rediscover the Web
    http://SpreadFirefox.com/ Igniting the Web

    Comment

    Working...