adapting code

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

    adapting code

    I have a need to insert a changing text with the .jpg into this code. Can
    you advise, please? I appreciate this newsgroup, Dick Ross

    <BODY>

    <SCRIPT LANGUAGE="JavaS cript">


    <!-- Begin
    today = new Date();
    day = today.getDay();
    arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
    "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;

    document.write( "<img src='" + arday[day] + "'>");
    // End -->
    </script>

    <p><center>
    <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
    by <a href="http://javascriptsourc e.com">The JavaScript Source</a></font>
    </center><p>

    <!-- Script Size: 0.63 KB -->


  • McKirahan

    #2
    Re: adapting code

    "ross" <rosmd@everestk c.net> wrote in message
    news:cb74f$43d6 9225$40971e23$2 4917@EVERESTKC. NET...[color=blue]
    > I have a need to insert a changing text with the .jpg into this code. Can
    > you advise, please? I appreciate this newsgroup, Dick Ross
    >
    > <BODY>
    >
    > <SCRIPT LANGUAGE="JavaS cript">
    >
    >
    > <!-- Begin
    > today = new Date();
    > day = today.getDay();
    > arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
    > "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
    >
    > document.write( "<img src='" + arday[day] + "'>");
    > // End -->
    > </script>
    >
    > <p><center>
    > <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
    > by <a href="http://javascriptsourc e.com">The JavaScript Source</a></font>
    > </center><p>
    >
    > <!-- Script Size: 0.63 KB -->[/color]

    Is this what your looking for?

    <script type="text/javascript">
    var now = new Date();
    var day = now.getDay();
    var arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
    "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
    var artxt = new Array("Sunday", "Monday", "Tuesday",
    "Wednesday" , "Thursday", "Friday", "Saturday") ;

    document.write( "<img src='" + arday[day] + "'>");
    document.write( "<br>Today is " + artxt[day]);
    </script>


    Comment

    • mick white

      #3
      Re: adapting code

      ross wrote:
      [color=blue]
      > I have a need to insert a changing text with the .jpg into this code. Can
      > you advise, please? I appreciate this newsgroup, Dick Ross
      >
      >
      > <SCRIPT LANGUAGE="JavaS cript">
      > today = new Date();
      > day = today.getDay();
      > arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
      > "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
      >
      > document.write( "<img src='" + arday[day] + "'>");
      > </script>
      >[/color]


      <script type="text/javascript">
      day = new Date().getDay() ;
      arday = ["sunday.jpg ", "monday.jpg ", "tuesday.jp g",
      "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.j pg"];
      artext = ["sunday text", "monday text", "tuesday text",
      "wednesday text", "thursday text", "friday text", "saturday text"];
      document.write(
      "<img src='" + arday[day] + "'>"+"<BR>"+art ext[day]);
      </script>

      Mick



      Comment

      • ross

        #4
        Re: adapting code

        I will give it a try. I am very inept at javascript, so I really appreciate
        your help,
        "McKirahan" <News@McKirahan .com> wrote in message
        news:_audnRwcZ9 WKC0venZ2dnUVZ_ tudnZ2d@comcast .com...[color=blue]
        > "ross" <rosmd@everestk c.net> wrote in message
        > news:cb74f$43d6 9225$40971e23$2 4917@EVERESTKC. NET...[color=green]
        >> I have a need to insert a changing text with the .jpg into this code. Can
        >> you advise, please? I appreciate this newsgroup, Dick Ross
        >>
        >> <BODY>
        >>
        >> <SCRIPT LANGUAGE="JavaS cript">
        >>
        >>
        >> <!-- Begin
        >> today = new Date();
        >> day = today.getDay();
        >> arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
        >> "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
        >>
        >> document.write( "<img src='" + arday[day] + "'>");
        >> // End -->
        >> </script>
        >>
        >> <p><center>
        >> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
        >> by <a href="http://javascriptsourc e.com">The JavaScript Source</a></font>
        >> </center><p>
        >>
        >> <!-- Script Size: 0.63 KB -->[/color]
        >
        > Is this what your looking for?
        >
        > <script type="text/javascript">
        > var now = new Date();
        > var day = now.getDay();
        > var arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
        > "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
        > var artxt = new Array("Sunday", "Monday", "Tuesday",
        > "Wednesday" , "Thursday", "Friday", "Saturday") ;
        >
        > document.write( "<img src='" + arday[day] + "'>");
        > document.write( "<br>Today is " + artxt[day]);
        > </script>
        >
        >[/color]


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: adapting code

          McKirahan wrote:
          [color=blue]
          > <script type="text/javascript">
          > var now = new Date();
          > var day = now.getDay();
          > var arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
          > "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ;
          > var artxt = new Array("Sunday", "Monday", "Tuesday",
          > "Wednesday" , "Thursday", "Friday", "Saturday") ;[/color]

          Since the names of files and weekdays are this similar, `artxt' is not
          necessary.
          [color=blue]
          > document.write( "<img src='" + arday[day] + "'>");[/color]

          The `img' element requires the `alt' attribute to provide for graceful
          degradation.
          [color=blue]
          > document.write( "<br>Today is " + artxt[day]);[/color]

          Consecutive calls of document.write( ) are inefficient and error-prone.
          [color=blue]
          > </script>[/color]

          <script type="text/javascript">
          var
          now = new Date(),
          arday = new Array("sunday.j pg", "monday.jpg ", "tuesday.jp g",
          "wednesday.jpg" , "thursday.j pg", "friday.jpg ", "saturday.jpg") ,
          wkday = arday[now.getDay()],
          txt = wkday.charAt(0) .toUpperCase()
          + wkday.substr(1) .replace(".jpg" , "");

          document.write(
          "<img src='" + wkday + "' alt='" + txt + "'>"
          + "<br>Today is " + txt);
          </script>

          It should be noted that the restrictions on correctness of client-side dates
          apply.


          PointedEars

          Comment

          Working...