Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript troubles

 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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!

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I just wish someone could help me.......
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
it screwed up my code again

 
Nick Harms
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the function getMap is located where?

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic