Not random text quotes

Discussion in 'Javascript' started by poeschlm@hotmail.com, Jan 5, 2005.

  1. Guest

    I am looking for some help in creating a script that will allow me to
    define an array and then display those array elements in sequence on
    page refresh. I can find as many random text scripts but I would like
    one that will go in order of my array. I appreciate any help.

    Mike
    , Jan 5, 2005
    #1
    1. Advertising

  2. Lee Guest

    said:
    >
    >I am looking for some help in creating a script that will allow me to
    >define an array and then display those array elements in sequence on
    >page refresh. I can find as many random text scripts but I would like
    >one that will go in order of my array. I appreciate any help.


    Learn about cookies.
    If there is no cookie (first visit or cookies disabled), show a
    random element. Otherwise, read the position in the array from
    the cookie.
    Lee, Jan 5, 2005
    #2
    1. Advertising

  3. RobB Guest

    wrote:
    > I am looking for some help in creating a script that will allow me to
    > define an array and then display those array elements in sequence on
    > page refresh. I can find as many random text scripts but I would

    like
    > one that will go in order of my array. I appreciate any help.
    >
    > Mike


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>untitled</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <style type="text/css">

    #Q {
    width: 400px;
    font: bold 16px times;
    text-transform: capitalize;
    text-align: center;
    border-top: 3px #000 double;
    border-bottom: 3px #000 double;
    }

    </style>
    </head>
    <body>
    <div id="Q"></div>
    <script type="text/javascript">

    var quotes = [
    'Lorem quotem 1 ipsum quotem 1 dolor quotem 1' ,
    'Lorem quotem 2 ipsum quotem 2 dolor quotem 2' ,
    'Lorem quotem 3 ipsum quotem 3 dolor quotem 3' ,
    'Lorem quotem 4 ipsum quotem 4 dolor quotem 4' ,
    'Lorem quotem 5 ipsum quotem 5 dolor quotem 5'
    ];

    var idx_arr, idx_str, el;
    if (!/__NOT_RANDOM_TEXT_QUOTES__/.test(top.name))
    {
    idx_arr = [];
    for (var i = 0; i < quotes.length; ++i)
    idx_arr.push(i);
    idx_str = idx_arr.join(',');
    }
    else idx_str = top.name.split('__NOT_RANDOM_TEXT_QUOTES__')[1];
    idx_arr = idx_str.split(',');
    var first_idx = idx_arr.splice(0, 1);
    if (el = document.getElementById('Q'))
    {
    while (el.hasChildNodes())
    el.removeChild(el.lastChild);
    el.appendChild(document.createTextNode(quotes[first_idx]));
    }
    idx_arr.push(first_idx);
    idx_str = idx_arr.join(',');
    top.name = '__NOT_RANDOM_TEXT_QUOTES__' + idx_str;
    </script>
    </body>
    </html>
    RobB, Jan 5, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,828
    Hermit Dave
    Sep 22, 2004
  2. Chris
    Replies:
    1
    Views:
    13,601
    Oisin
    Mar 24, 2006
  3. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,480
    Andrew Thompson
    Dec 24, 2003
  4. globalrev
    Replies:
    4
    Views:
    741
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,113
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page