www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23

Thread: Need help writing java script for an html, please look.

  1. #16
    Join Date
    Mar 2010
    Posts
    2,803
    ok, at least you know document.write(timeStr) is working.

    Now you need to do some basic debugging.

    Maybe try the following:

    add an alert() as show below:

    Code:
     
     alert("mapNum = "+mapNum);
    document.write("<img id='sky' src='"+mapNum+".jpg' alt=' ' />");
    Say mapNum = 5, then make sure there is a file called 5.jpg in the same folder as the folder where your html file is.

  2. #17
    Join Date
    Apr 2010
    Posts
    11
    Quote Originally Posted by tirna View Post
    ok, at least you know document.write(timeStr) is working.

    Now you need to do some basic debugging.

    Maybe try the following:

    add an alert() as show below:

    Code:
     
     alert("mapNum = "+mapNum);
    document.write("<img id='sky' src='"+mapNum+".jpg' alt=' ' />");
    Say mapNum = 5, then make sure there is a file called 5.jpg in the same folder as the folder where your html file is.
    actually the files are called sky0-sky23

  3. #18
    Join Date
    Mar 2010
    Posts
    2,803
    Then use

    Code:
     
    document.write("<img id='sky' src='sky"+mapNum+".jpg' alt=' ' />");
    and if the images are in a different folder to the one your html file is in then you have to insert the relative folder path to images' folder infront of 'sky'

  4. #19
    Join Date
    Apr 2010
    Posts
    11

    Smile

    Quote Originally Posted by tirna View Post
    Then use

    Code:
     
    document.write("<img id='sky' src='sky"+mapNum+".jpg' alt=' ' />");
    and if the images are in a different folder to the one your html file is in then you have to insert the relative folder path to images' folder infront of 'sky'
    YOU ARE MY HERO!!!! THANK YOU SO MUCH!
    I see your from australia, im from ks in the states, I would love to visit you all down there though, Keith Urban is the reason I started playing guitar!
    Cheers!
    Have a wonderful weekend and thanks again!
    Nick

  5. #20
    Join Date
    Mar 2010
    Posts
    2,803
    no problem - happy to help and I'm glad you sorted it out

  6. #21
    Join Date
    May 2010
    Posts
    1

    Unhappy I'm having the same problem.

    Hello

    I was lucky enough to find this forum. I have compared the work from this page to mine and so far it looks fine but I don't understand why my page is still not showing anything. The picture files are all in the same folder as the codes so I know it is not a 'files in separate folder' issue. I'm pissed and my head is swimming. I have a splitting headache from staring at my screen for hours. Help meeeeeeeee

    my codes:

    Filename: skymap.htm
    Supporting files: datetime.js, mask.gif, sky0.jpg - sky23.jpg, skyweb.css,
    -->

    <title>SkyWeb: The Planisphere</title>
    <link href="skyweb.css" rel="stylesheet" type="text/css" />

    <script src="datetime.js" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    timeStr is a text string containing the current date and time mapNum is the number of

    the map to display in the planisphere.
    */

    var timeStr = showDateTime(date, time);
    var mapNum = getMap();

    </script>
    </head>

    <body>
    <div id="pageContent">

    <div id="logo">
    <img src="skyweb.jpg" alt="SkyWeb" />
    </div>

    <div id="maps">
    <script type="text/javascript">
    document.write("<img id='sky' src='sky"+mapNum+" .jpg' alt=' ' />");
    </script>
    <img id="mask" src="mask.gif" alt="" />
    <div id="datetime">
    <script type="text/javascript">
    document.write(timeStr);
    </script>
    </div>
    </div>

    <div id="content">
    <h1>The Planisphere</h1>
    <p>A <b>planisphere</b> is a visual aid to astronomers and stargazers.
    It consists of two disks: one displays all of the visible
    constellations in the night sky, and the other covers the first
    and contains a window that indicates the portion of the sky currently
    visible. The second disk is then rotated to match the current date and
    time. Planispheres come in a variety of sizes and types. The important
    thing to remember is that you must have a planisphere that matches
    the longitude of your stargazing location.</p>
    <p>On the right is an online planisphere. It consists of two images. The
    bottom image contains the sky map; the top image contains the viewing
    window. Rather than turning the viewing window, this planisphere is
    automatically rotated for you, displaying the current date and time
    and visible constellations for observers at a longitude of
    40<sup>&deg;</sup> North. To update the planisphere you can click
    the <span class="button">Refresh</span> or
    <span class="button">Reload</span> button on your browser. The planisphere
    will change, representing the nighttime sky to the nearest hour.</p>
    </div>

    <div id="links">
    | <a href="#">Home Page</a>
    | <a href="#">The Night Sky</a>
    | <a href="#">The Moon</a>
    | <a href="#">The Planets</a>
    | <a href="#">The Messier Objects</a>
    | <a href="#">Stars</a> |
    </div>

    </div>
    </body>
    </html>

  7. #22
    Join Date
    Sep 2011
    Posts
    1
    Hi...

    I AM HAVING THE EXACT SAME PROBLEM!!!

    As far as I can tell, I'm not doing anything differently from the first guy, I even included the fixes he used. It's all in the same folder. Heres what I got.

    <?xml version="1.0" encoding="UTF-8" ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <!--
    New Perspectives on HTML and XHTML 5th Edition
    Tutorial 10
    Case Problem 1

    SkyWeb Planisphere
    Author: Marcus Gilliland
    Date: 09/12/2011
    SN: 201106w0001
    Assignment: 6982B-3

    Filename: skymap.htm
    Supporting files: datetime.js, mask.gif, sky0.jpg - sky23.jpg, skyweb.css,
    -->

    <title>SkyWeb: The Planisphere</title>
    <link href="skyweb.css" rel="stylesheet" type="text/css" />
    <script src="datetime.js" type="text/javascript"></script>
    <script type="text/javascript">
    /*
    timeStr is a text string containing the current date and time
    mapNum is the number of the map to display in the planisphere
    */
    var timeStr=showDateTime();
    var mapNum=getMap();
    </script>
    </head>

    <body>
    <div id="pageContent">

    <div id="logo">
    <img src="skyweb.jpg" alt="SkyWeb" />
    </div>

    <div id="maps">
    <script type="text/javascript"
    document.write("<img id='sky' src='sky"+mapNum+".jpg' alt=' ' />")
    </script>
    <img id="mask" src="mask.gif" alt="" />
    <div id="datetime">
    <script type="text/javascript"
    document.write(timeStr);
    </script>
    </div>
    </div>

    <div id="content">
    <h1>The Planisphere</h1>
    <p>A <b>planisphere</b> is a visual aid to astronomers and stargazers.
    It consists of two disks: one displays all of the visible
    constellations in the night sky, and the other covers the first
    and contains a window that indicates the portion of the sky currently
    visible. The second disk is then rotated to match the current date and
    time. Planispheres come in a variety of sizes and types. The important
    thing to remember is that you must have a planisphere that matches
    the longitude of your stargazing location.</p>
    <p>On the right is an online planisphere. It consists of two images. The
    bottom image contains the sky map; the top image contains the viewing
    window. Rather than turning the viewing window, this planisphere is
    automatically rotated for you, displaying the current date and time
    and visible constellations for observers at a longitude of
    40<sup>&deg;</sup> North. To update the planisphere you can click
    the <span class="button">Refresh</span> or
    <span class="button">Reload</span> button on your browser. The planisphere
    will change, representing the nighttime sky to the nearest hour.</p>
    </div>

    <div id="links">
    | <a href="#">Home Page</a>
    | <a href="#">The Night Sky</a>
    | <a href="#">The Moon</a>
    | <a href="#">The Planets</a>
    | <a href="#">The Messier Objects</a>
    | <a href="#">Stars</a> |
    </div>

    </div>
    </body>
    </html>


    This is a sos.

  8. #23
    Join Date
    Aug 2014
    Posts
    1
    Quote Originally Posted by tirna View Post
    Then use

    Code:
     
    document.write("<img id='sky' src='sky"+mapNum+".jpg' alt=' ' />");
    and if the images are in a different folder to the one your html file is in then you have to insert the relative folder path to images' folder infront of 'sky'
    I had the same problem as Drumfreak and I really appreciate tirna’s reply to this problem. Thank you so much, ur the best.
    I still cant understand y its not written clearly in the book to add sky in that step.
    The book is not so bad but I have found many mistakes everywhere.
    And again to clarify mavigozler, document.write definitely exists in xhtml.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles