473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

need to change src attr of a destination image from one this clicked on

Hi Group,

Inside of an img tag I have an onclick that fires a function. The
function is supposed to change the src of a larger image elsewhere on
the page. Think: click the thumbnail to see it at the enlarged_image
that is on the page.

I tried this function but it doesnt work =/

function doit(){
var node = this;
var nodesrc = node.getAttribute("src");
dest_img.setAttribute("src", nodesrc);
}

I dont think 'this' is doing what I want it to, plus I get the error
that node.getAttribute() is not a function.

Please can someone offer some direction on how I can solve this
problem?
Thanks in advance for any help.

Regards,
DE

Sep 5 '07 #1
2 1282
On 5 , 07:53, deepsnow <daneens...@gmail.comwrote:
Hi Group,

Inside of an img tag I have an onclick that fires a function. The
function is supposed to change the src of a larger image elsewhere on
the page. Think: click the thumbnail to see it at the enlarged_image
that is on the page.

I tried this function but it doesnt work =/

function doit(){
var node = this;
var nodesrc = node.getAttribute("src");
dest_img.setAttribute("src", nodesrc);

}

I dont think 'this' is doing what I want it to, plus I get the error
that node.getAttribute() is not a function.

Please can someone offer some direction on how I can solve this
problem?
Thanks in advance for any help.

Regards,
DE
Try this
<img src="some.gif" onclick="doit(event)">

function doit(e)
{
var node = e.target || e.srcElement;
var nodesrc = node.src;
dest_img.src = nodesrc;
}

Mykola
http://marss.co.ua

Sep 5 '07 #2
pr
deepsnow wrote:
function doit(){
var node = this;
var nodesrc = node.getAttribute("src");
dest_img.setAttribute("src", nodesrc);
}
'this' in this instance probably refers to the window. Try

<img src="x" onclick="doit(this)"/>

and

function doit(node) {...

to get the node you expect.
Sep 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sorby | last post by:
Hi I've been coding in PHP for a little while now and was starting to feel pretty confident but then realise I need to understand regular expressions to solve a particular problem I've got ......
21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
3
by: Steve | last post by:
Hi, I have a nice little script that works well displaying images on my website. It's a script where if you clik a thumbnail image a pop up window opens that contains a larger version of the same...
3
by: Tom Sweet | last post by:
Hi I know how to use the bitmap and graphics objects to create bitmaps and write text on them with the drawString method. I now need to create some BMPs of word or RTF docs. What would be the...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
1
by: not_a_commie | last post by:
I recognize that the need for this spells a serious flaw in the program design, but I need to copy a portion out of a Graphics object and put that into an Image object. How do I do it generically?...
5
by: Joseph Barillari | last post by:
Hi python-list, I've just started using new-style classes and am a bit confused as to why I can't seem to alter methods with special names (__call__, etc.) of new-style class instances. In other...
0
by: zeckdude | last post by:
Hi, I am having some issues with my site. I have a main Nav with four links that load in 4 different sections. You can see the page I am working on here:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.