Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2005, 02:51 AM   PM User | #1
BigPete
New Coder

 
Join Date: Mar 2005
Location: Pennsylvania, USA
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
BigPete is an unknown quantity at this point
Question Tell me what's wrong

I have a pretty simple javascript on my site. I'm not the best with Javascript, so could someone tell me what is wrong. Here's the Javascript.
Code:
<script language="Javascript" type="text/javascript">
<!--
function viewpic(A,B,C)
	{
	 document.getElementByName("bigpicture").src=A
	 document.getElementByName("bigpicture").alt=B
	 document.getElementById("descriptiondiv").innerHTML="<p>" + C + "</p>"
	}
//-->
</script>
My HMTL (condensed) is:
Code:
<a href="Javascript:viewpic(images/me.jpg,Picture of Me,This is a picture of me.)">Picture of me</a>
<br><br>
<img src="images/something.jpg" name="bigpicture" alt="picture"><br>
<div id="descriptiondiv"></div>
What is supposed to happen is - you click on the link that says Picture of Me (actually there will be lots of pictures) and the image by the name of "bigpicture" should change it's source and alternate text. Also a small description will get put in the div. It doesn't do any of that, and my FireFox Javascript Console didn't give me any error message, so I'm not sure what's wrong. Please help me out.
BigPete is offline   Reply With Quote
Old 03-10-2005, 04:08 AM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
There is no getElementByName method but getElementsByName and getElementsByTagName. But you won't need them.

document.images["bigpicture"].src=A

or if you give an id to the image.

document.getElementById("bigpicture").src=A
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:08 PM.


Advertisement
Log in to turn off these ads.