Connecting Tech Pros Worldwide Help | Site Map

Changings the onClick of a image.

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 07:07 PM
Ben
Guest
 
Posts: n/a
Default Changings the onClick of a image.

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.getElementsByName("image1")[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.

  #2  
Old July 23rd, 2005, 07:07 PM
Lee
Guest
 
Posts: n/a
Default Re: Changings the onClick of a image.

Ben said:[color=blue]
>
>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.getElementsByName("image1")[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.[/color]

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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.