• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript troubles

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok , the problem is

Scroll down to the div element with id value maps and replace the line
<img id="sky" src="sky0.jpg" alt="" />
with a script element that writes the following html code:
<img id='sky' src='mapNum.jpg' alt=' ' />
were mapNum is the value of the mapNum Variable.

I've been redoing this several times and can't seem to get everywhere,
I had to do a similar thing with the clock but got it to work right away.

Any help is greatly appreciated!

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on Java. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just wish someone could help me.......
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You haven't done a particularly god job of letting us know what problem you are having.
 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You haven't done a particularly god job of letting us know what problem you are having.



# <script type="text/javascript">
# document.write('<img id="sky" ' />');
# </script>

That's what I have so far, I don't know how to explain it any better, I copied the question out of the book, did my best to try it for myself and the image is not displaying.
I need help to figure out what is wrong with my script and why it is not doing what the book wants it to do.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When posting HTML be sure to click the 'disable HTML' checkbox.

First, you need to fix your syntax. Your quoting is wrong.

Second, if the image tag doesn't have a src attribute to identify its image file, of course nothing will appear.
 
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nick,

I still don't understand what the question is.

What have you tried? What is is supposed to do? What part(s) of what it's supposed to do isn't it doing?

"It doesn't work" doesn't help anyone to help you.
 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:When posting HTML be sure to click the 'disable HTML' checkbox.

First, you need to fix your syntax. Your quoting is wrong.

Second, if the image tag doesn't have a src attribute to identify its image file, of course nothing will appear.



Well here is what I have now
If the quoting is still wrong that's what I need help on, and what that last part posted isn't what I wanted to post anyways, it did have a src
Can you help me from this further? It is still not showing an image.

 
Janeice DelVecchio
Bartender
Posts: 1849
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That quoting doesn't look like the quoting in the example:



EDIT -- Crap.... the stupid forum ate my code.
Check line 45 in the example
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, that looks a little better.

Is there really an image file with the resulting name in the same folder as the HTML file?

By the way, using a tool like Firebug in Firefox will let you look at the active HTML DOM so you can see what the result of your statement actually becomes in the DOM.

Chrome also has such tools.
 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:OK, that looks a little better.

Is there really an image file with the resulting name in the same folder as the HTML file?

By the way, using a tool like Firebug in Firefox will let you look at the active HTML DOM so you can see what the result of your statement actually becomes in the DOM.

Chrome also has such tools.



well the mapNum variable is referencing the getMap() function,
My book says The getMap() function which returns a number from 0 to 23. The number matches the number of the sky map image to show based on the current date and time. That function has been placed in an external javascript file named datetime.js which you can see I accessed in the top of the code.
The timeStr also refers to a function in that file and it actually works. In the project folder there are 0-23 images and I guess the function reads the time and displays the apropriate picture.

My task was this
4. Scroll down the file to the div element with the id value maps and replace the line
(which is now gone) with a script element that writes the following html code.

where mapNum is the value of the mapNum variable
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your post is screwed up again. Please pay attention to the checkboxes beneath the posting box and set them appropriately.
 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it screwed up my code again

 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully all that information helps. There is not a specific image with that name as you asked before, the function selects the image depending on the time. I am pretty sure thats how it works.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the function getMap is located where?

Eric
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic