help

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

    #1

    help

    I have figured out how to have text change according to the day of the
    week - what I want to do is to ad an accompanying picture, which also
    changes according to the day of the week.

    Any ideas on how to help me??????

    This is how I did the text:

    <script language="JavaS cript">
    <!--
    function quick() {

    var mydate=new Date()
    var day=mydate.getD ay()
    var month=mydate.ge tMonth()
    var daym=mydate.get Date()
    if (daym<10)
    daym="0"+daym
    var qfarray=new Array("text 1.",
    "text 2.",
    "text3.",
    "text4",
    "text5.",
    "text6.",
    "text7.")
    document.write( "<small><fo nt face='Times New Roman'>"+qfarra y[day])}
    // -->
    </script>


    <script language="JavaS cript">
    <!--
    quick()
    //-->

    </script>



  • web.dev

    #2
    Re: help

    Prophet,

    Here's a quick and dirty solution You can do the following:
    Make an array with path to your seven images:

    var imgarray = new Array("../images/day1.jpg", "../images/day2.jpg",
    etc..);

    Then to display your image:

    document.write( "<img src = '" + imgarray[day] + "'/>");

    :) Hope it helps.

    Comment

    • Prophet

      #3
      Re: help

      I will give it a try - thank you

      "web.dev" <web.dev.cs@gma il.com> wrote in message
      news:1117663108 .567547.269860@ o13g2000cwo.goo glegroups.com.. .[color=blue]
      > Prophet,
      >
      > Here's a quick and dirty solution You can do the following:
      > Make an array with path to your seven images:
      >
      > var imgarray = new Array("../images/day1.jpg", "../images/day2.jpg",
      > etc..);
      >
      > Then to display your image:
      >
      > document.write( "<img src = '" + imgarray[day] + "'/>");
      >
      > :) Hope it helps.
      >[/color]


      Comment

      • Prophet

        #4
        Re: help

        So I tried it, but it does not show the actual picture - there is just the
        box which shows that there should be a picture in its place

        "web.dev" <web.dev.cs@gma il.com> wrote in message
        news:1117663108 .567547.269860@ o13g2000cwo.goo glegroups.com.. .[color=blue]
        > Prophet,
        >
        > Here's a quick and dirty solution You can do the following:
        > Make an array with path to your seven images:
        >
        > var imgarray = new Array("../images/day1.jpg", "../images/day2.jpg",
        > etc..);
        >
        > Then to display your image:
        >
        > document.write( "<img src = '" + imgarray[day] + "'/>");
        >
        > :) Hope it helps.
        >[/color]


        Comment

        • Prophet

          #5
          Re: help

          got it - THANKS!!!!


          "web.dev" <web.dev.cs@gma il.com> wrote in message
          news:1117663108 .567547.269860@ o13g2000cwo.goo glegroups.com.. .[color=blue]
          > Prophet,
          >
          > Here's a quick and dirty solution You can do the following:
          > Make an array with path to your seven images:
          >
          > var imgarray = new Array("../images/day1.jpg", "../images/day2.jpg",
          > etc..);
          >
          > Then to display your image:
          >
          > document.write( "<img src = '" + imgarray[day] + "'/>");
          >
          > :) Hope it helps.
          >[/color]


          Comment

          • web.dev

            #6
            Re: help

            Are you sure the path to where your image is correct? Or if the image
            even exists? If yes to both, then you could even consider that the
            browser might not even know how to display that picture, which are rare.

            Comment

            • Lee

              #7
              Re: help

              Prophet said:[color=blue]
              >
              >So I tried it, but it does not show the actual picture - there is just the
              >box which shows that there should be a picture in its place[/color]

              Make sure the paths in the array actually point to your images.
              To be absolutely sure, you can give the full URL
              ("http://whatever/whatever.gif").

              When responding to posts, you should put your response *after* the
              text you're responding to, and, in the future, please try to think
              of a subject line that tells us what sort of problem you need help
              with. Nearly everyone who starts a thread is looking for "help".

              Comment

              • Prophet

                #8
                Re: help


                "web.dev" <web.dev.cs@gma il.com> wrote in message
                news:1117663108 .567547.269860@ o13g2000cwo.goo glegroups.com.. .[color=blue]
                > Prophet,
                >
                > Here's a quick and dirty solution You can do the following:
                > Make an array with path to your seven images:
                >
                > var imgarray = new Array("../images/day1.jpg", "../images/day2.jpg",
                > etc..);
                >
                > Then to display your image:
                >
                > document.write( "<img src = '" + imgarray[day] + "'/>");
                >
                > :) Hope it helps.
                >[/color]

                Now that I have the picture showing, how do I insert formatting commands
                such as 'center' or 'height = 78' etc.


                Comment

                • Prophet

                  #9
                  Re: help


                  "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                  news:d7ld6s01q5 k@drn.newsguy.c om...[color=blue]
                  > Prophet said:[color=green]
                  >>
                  >>So I tried it, but it does not show the actual picture - there is just the
                  >>box which shows that there should be a picture in its place[/color]
                  >
                  > Make sure the paths in the array actually point to your images.
                  > To be absolutely sure, you can give the full URL
                  > ("http://whatever/whatever.gif").
                  >
                  > When responding to posts, you should put your response *after* the
                  > text you're responding to, and, in the future, please try to think
                  > of a subject line that tells us what sort of problem you need help
                  > with. Nearly everyone who starts a thread is looking for "help".
                  >[/color]

                  When responding, the cursor automatically goes to the *TOP* of the page, so
                  I naturally just start typing - I knew that 'help' was not a very good
                  subject, but I could not think of anything that was eye catching and matched
                  the nature of the question.

                  please bare with me as I am learning!

                  Thank you for the guidance - Mark


                  Comment

                  • Richard Cornford

                    #10
                    Re: help

                    Prophet wrote:[color=blue]
                    > web.dev wrote:[color=green]
                    >> Here's a quick and dirty solution ... :[/color][/color]
                    <snip>[color=blue]
                    > Now that I have the picture showing, how do I insert
                    > formatting commands such as 'center' or 'height = 78' etc.[/color]

                    Formatting isn't done with commands, it is presentational so it is done
                    with CSS, with the exception of the dimensions of the image, which
                    probably should be in the form of attributes in the CSS string. If all
                    of the images are the same size then the attributes can be written into
                    the string of HTML that is being written. If the image sizes vary then
                    the IMG URLs and width and height information could be stored in an
                    array of objects, e.g.:-

                    var imgData = [
                    {
                    url:'images/sunday.gif',
                    width:50,
                    height:50
                    },
                    {
                    url:'images/monday.gif',
                    width:60,
                    height:50
                    },
                    {
                    url:'images/tuesday.gif',
                    width:70,
                    height:50
                    },
                    {
                    url:'images/wednesday.gif',
                    width:50,
                    height:60
                    },
                    {
                    url:'images/thursday.gif',
                    width:50,
                    height:70
                    },
                    {
                    url:'images/friday.gif',
                    width:90,
                    height:90
                    },
                    {
                    url:'images/saturday.gif',
                    width:30,
                    height:150
                    }
                    ];

                    The data can be concatenated into a string, or assembled into an Array
                    of strings that is later joined to form the HTML output:-

                    var imgOut = [
                    '<img src="',
                    '', // index 1
                    '" width="'
                    '', // index 3
                    '" height="',
                    '', // index 5
                    '">'
                    ];

                    var day=mydate.getD ay()

                    The object for a particular day can be recovered from the array in the
                    same way that the URL string has previously been recovered, by indexing
                    the Array with the week day number:-

                    var imgDayObject = imgData[day];

                    - and the individual pieces of information retrieved from that object by
                    name (and assigned to slots in the output array in this case):-

                    imgOut[1] = imgDayObject.ur l;
                    imgOut[3] = imgDayObject.wi dth;
                    imgOut[5] = imgDayObject.he ight;

                    And then the whole can be output using - document.write - (or other
                    techniques). In this case the array is assembled into a single string
                    using the Array's join method (joining the Array elements with an empty
                    string between elements, so as not to alter the output):-

                    document.write( imgOut.join('') );

                    Richard.


                    Comment

                    • Richard Cornford

                      #11
                      Re: help

                      Prophet wrote:[color=blue]
                      > Lee wrote:[/color]
                      <snip>[color=blue][color=green]
                      >> When responding to posts, you should put your response *after*
                      >> the text you're responding to, and, in the future, please try
                      >> to think of a subject line that tells us what sort of problem
                      >> you need help with. ... .[/color][/color]
                      <snip>[color=blue]
                      > When responding, the cursor automatically goes to the *TOP* of
                      > the page, so I naturally just start typing[/color]

                      The cursor starting at the top provides an opportunity to work down
                      through the document snipping the parts that are not going to be
                      responded to, and inserting responses after whatever is left.
                      [color=blue]
                      > - I knew that 'help' was not a very good subject,
                      > but I could not think of anything that was eye catching[/color]

                      Don't try to be eye catching, try to be informative. A subject header
                      that states the real subject is only likely to result in people who have
                      no interest in the subject being put off reading it, and those
                      individuals probably wouldn't be much help anyway (but you still don't
                      want to be wasting their time in case you later have a question with a
                      subject in which they are interested).
                      [color=blue]
                      > and matched the nature of the question.[/color]

                      The nature of the question is not necessarily relevant either. It is the
                      _subject_ of the question that should appear in the subject header. The
                      subject here appears to be; displaying one of a selection of images
                      based on the day of the week.
                      [color=blue]
                      > please bare with me as I am learning![/color]

                      Then you will want to read this group's FAQ:-

                      <URL: http://jibbering.com/faq >

                      - and save anyone else having to point out to you anything else that it
                      covers.

                      Richard.


                      Comment

                      Working...