473,666 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changings the onClick of a image.

Ben
Hi,

I have a number of images whose src's are changed when a button is
pressed. At the moment the href is also changed and the images are
opened. However I have a function which opens the images in their own
windows. I want to run this for each image using the onClick event of
the image. I have all the images and links stored in there own
array's. I would like to do the same for the onClick events. I have
tried creating an array an storing the onClick events in it.
i.e. images_onClicks[2] =
"image_popup('i mage.jpg',100,1 00,100,100)";
and then changing the onclick event for the image.
i.e. document.getEle mentsByName("im age1")[0].onclick =
images_onClicks[0];

However I just can't get it to work. Could anyone please tell me if
there is something that I am missing.

Thanks for your time.

Ben.
Jul 23 '05 #1
1 1717
Lee
Ben said:

Hi,

I have a number of images whose src's are changed when a button is
pressed. At the moment the href is also changed and the images are
opened. However I have a function which opens the images in their own
windows. I want to run this for each image using the onClick event of
the image. I have all the images and links stored in there own
array's. I would like to do the same for the onClick events. I have
tried creating an array an storing the onClick events in it.
i.e. images_onClicks[2] =
"image_popup(' image.jpg',100, 100,100,100)";
and then changing the onclick event for the image.
i.e. document.getEle mentsByName("im age1")[0].onclick =
images_onClick s[0];

However I just can't get it to work. Could anyone please tell me if
there is something that I am missing.


Three things:

1. The onclick attribute of an image must be a function.
You're trying to assign string values, not functions.

2. That's a very bad approach to the problem. You shouldn't
be changing the entire functions just to change the arguments
to your image_popup() function.

3. At least two people responded when you asked the same question
at least twice before. If you're not happy with those answers,
respond to them explaining why.

Jul 23 '05 #2

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

Similar topics

2
4434
by: Rob Manger | last post by:
Hi All, I am hoping someone can help me. I am trying to setup my main page so that when the user moves the mouse over an image, it changes the source (got this working). When the user CLICKS on the image (it is a link to the content page) it changes to a third image AND STAYS THERE. ie: so the iamge won't change back to the omouseoff image. Does this make sense? Also, how do I "preload" the images before they are even needed? eg:...
2
9158
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display in the status bar 'Symantec Corporation' whenever anyone mouses over (onMouseOver) my image or link OR when one clicks while holding the left mouse down (onClick) on the same image or link. Upon releasing the mouse (onMouseOut), the
2
4078
by: WindAndWaves | last post by:
Hi Folk I have an image map (map of New Zealand with various areas defined using an image map). Now I am wondering if it is possible to link this "image map" to an onclick and onmouseover event. Any ideas? - TIA
7
1539
by: Tim::.. | last post by:
Can someone please tell me how i execute an onClick event in an asp:Image tag! I want to do the following! Thanks! <asp:Image runat="server" ID="ibtnExpandResource" ImageUrl="../images/user.gif" onClick="Javascript: OnPlusClick(this);" style="cursor:hand;"></asp:Image>
4
13551
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of image is fired with event.keyCode as undefined. I was expecting that the form would get submitted. I tried returning from onclick() handler if keyCode is null, but the
1
386
by: webdeveloper | last post by:
An onclick event that activates two functions: one that expands a menu, another that swaps an image in the same menu hierarchy; in FF, only one click is required to both swap the image and expand the menu, as is intended. But in IE(6X) one click is required for swapping the image, and a second click to expand the menu. And in IE, on all subsequent clicks, just one click is required for both functions to fire, but the result is that the...
1
3672
by: Miroslav Stampar [MCSD.NET / Security+] | last post by:
I have a problem that is best described by following code: <a href="http://www.google.com" onclick="new Image().src=\'http:// www.example.com/process.cgi?p=1\'">Google</a> I want to call cgi script before a link is clicked. Upper example works as a standalone (AS IS), but... But, when I attach onclick event programmaticaly, clicked link loads to fast so image/CGI script doesn't have time to preload. Do you have
5
2640
by: prathapavp | last post by:
hi all, We r working on ERP sys and am doing crossBrowser compatibility. The problem is am not able to load one function by onClicking the refrence text . could u please help me out.
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.