This Message Forum is no longer in use

Please use the new Bravenet Help Forums FOUND HERE

General Forum
This Forum is Locked
Author
Comment
RE: Dynamic Content Change!

Hi There

As I am still learning HTML, I was using the test code for 'A simple dynamic Content Change' as follows:

H2Me Feeling SPAN id="emotion">Happy/ENDSPAN&H2
IMG id="photo" src = "C:UsersJenniferPicturesJenMarch06.jpg" alt = "[Jenny feeling Happy]" ="change();"ENDIMG

SCRIPT type = "text/javascript"
COMMENT
function change()
{if(emotion.innerHTML=="Happy")
{photo.src="C:UsersJenniferPicturesJenMarch06.jpg"
emotion.innerhtml="Sad";}
else
{photo.src="C:UsersJenniferPicturesIMG_0454.jpg";
emotion.innerhtml="Happy";}
}
END COMMENT
SCRIPT
BODY



It doesn't actually work . It's wierd, I got the code from a text book. I ran the code through 'validator' on the W3C website and it say's it valid.

Try using paths to two images on your computer in place of mine and see if the image actually changes when you click on it. Mine let's you click on it and then even though the path is valid it comes up with the red cross "image not found". Also the text doesn't change to 'Sad'.

I hope you can help, thanks Jen

PS I have replaced tags with capitalized explanations to stop the page rendering it as HTML. I've also missed out the head, title, body and opening and closing HTML tags. Remember it has passed as valid code so I'm stumped at what;s going wrong on this one!

Re: RE: Dynamic Content Change!

Forget dynamic content change for the moment.

doesn't work. Not even after I created a picture named UsersJenniferPicturesIMG_0454.jpg on my C: drive.


works - if the html file is also in the root directory.

So does


But that file name sounds to me as if you are trying to say something like
localhost/C:/Users/Jennifer/Pictures/IMG_0454.jpg

That is of course not to say that there is nothing else wrong with your code, I was just to lazy to even try to understand what you had changed.

Re: RE: Dynamic Content Change!

Don't try to post HTML/Javascript unless your really know how. Mucking up the tags makes it doubly hard to figure out where the problem might be. It's far better to just create a test page and give us the URL. We know how to view the code.

The Markup Validation Service by the World Wide Web Consortium (W3C) allows Internet users to check HTML documents for conformance to HTML or XHTML standards. It also provides a quick method for web page authors to check their posted pages for mark-up errors.

This is a quote from Wikipedia W3C Markup Validation Service page. The key words in the quote are "conformance" and "mark-up errors". All validation tells you is that your tags are structured correctly and that you didn't have any mark-up errors, like overlapping divs or unterminated structures. It doesn't tell you whether anything is going to work as you expect. But your original code only "tentatively" validated. It needed the DOCTYPE and UTF-8 definitions to successfully validate.

With a few minor corrections, the code works just fine. Here is a link to a Dynamic Content Test Page I made from your code. You can use your right mouse button to view the code.

I did a slight re-arrangement, putting the Javascript between the and tags, and putting the HTML between the and tags. Then I corrected the spelling in the Javascript. While HTML is not case sensitive, Javascript certainly is. In two of the lines you spelled "innerHTML" as "innerhtml". W3C Validation would not have told you about those errors.

Re: RE: Dynamic Content Change!

Hello All

Corwings I did use the ' ' in the filepath. Sorry I was just really struggling to get the html to display as text.

Thanks for the tips Philo kvetch :-)

I'll check out the link/code later. Link isn't working at the mo.

Merry Christmas

Re: RE: Dynamic Content Change!

The link appears to be working just fine, but that web host is sometimes a little slow to respond. When you get there, just click on the happy face.

Is anyone else having problems with the link?

Re: RE: Dynamic Content Change!

Philo, I had no problem with the link.

Re: RE: Dynamic Content Change!

Link works fine. But is it suppose to show anything but a happy face? All I ever get is the happy face.

Re: RE: Dynamic Content Change!

Sorry Guyz this is all I ever get when I follow the link!

Network Error (tcp_error)


A communication error occurred: "Operation timed out"
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.

For assistance, contact your network support team.

Re: RE: Dynamic Content Change!

Link works fine. Also found my glasses, and can read again, so ignore last question.

Re: RE: Dynamic Content Change!

Yes, I should have probably posted some instructions. The way it is suppose to work is, if you left click your mouse on the happy face, the happy face should turn to a sad face and the word "Happy" should change to "Sad".

I thought there might have been some problem with the code, so I did a little more work. While I could get it to work fine in Firefox and IE, it wouldn't work at all in Netscape 7.2. So I did a little rework and rewrote it a little. But even after the rework, I could not get it to completely work in Netscape. The text would change but the image would not. The code in the link below is the updated code and should work in any up to date browser. I won't put any more effort into making Netscape work, because the version I have is just too old.

jayabee3,

As I said, the web site is a little slow, but I have never had anyone have problems with it again. I don't know where you connecting from, so there isn't much I can do. This sounds like there is an issue with your ISPs DNS. But I put the code on another server. Try this link to the Dynamic Content Test page.

Re: RE: Dynamic Content Change!

Philo Kvetch

Thanks very much the second link worked. I'll study the code. :-)

Regards
jayabee3

Re: RE: Dynamic Content Change!

Philokvetch

I've got the code to work in my example now. Thankyou.

I've tried to use the same method to make a "transitional banner". However I want the banner image to change on the page/image load event.

Within the img tag I have onload="Change();"
The script for Change in PseudoCode:
If as is on page load the image is 'test1.jpg' then
change the image to 'test2.jpg'.
When the image is 'test2.jpg' change the image to 'test3.jpg'.

i.e. I want the banner to cycle through 3 images and end up with a static banner; 'test3.jpg'.
With all the syntax as in your example should this work in theory?

Or does anyone have any better suggestions of how to go about it?

Many Thanks
jayabee3