473,321 Members | 1,877 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,321 software developers and data experts.

subroutines

hi, I have recently tried to make a web page where there is a number
of pictures each named with a number (1,2,3,4,5 etc). I then have
links on the page which are supposed to change the picture. I know
how to do this with the onclick event. However, I want to run several
other things when the link is clicked. Therefore I put a subroutine
that accepts the pictures name in the subroutine like this:
onclick="top.dostuff(4)" This executed the sub ok. However I also
wanted to change the picture so I tried to do it like this:

function dostuff(picnumber) {
var picture = new Image;
picture.src ="alternativepic.gif";
document.picnumber.src = picture;
}

with the link like this:

<img src="a.gif" name="1"> <a href="#" onclick="dostuff(1)"> 1 </a>
<img src="a.gif" name="2"> <a href="#" onclick="dostuff(1)"> 2 </a>
<img src="a.gif" name="3"> <a href="#" onclick="dostuff(1)"> 3 </a>

As you can see I want to be able to change the specific picture
depending on the value of picnumber. Any ideas?
Jul 20 '05 #1
3 2180
Hi,

I am not sure if you can name your picture 1, 2, 3
I think that a name should start with a letter or underscore.

Try this:

function dostuff(picnumber) {
document.images["pic"+picnumber].src="somethingelse.pic";
}

with the link like this:

<img src="a.gif" name="pic1"> <a href="#" onclick="dostuff(1)"> 1 </a>
<img src="a.gif" name="pic2"> <a href="#" onclick="dostuff(2)"> 2 </a>
<img src="a.gif" name="pic3"> <a href="#" onclick="dostuff(3)"> 3 </a>
Good luck,
Erwin Moller
Jul 20 '05 #2
Erwin Moller <si******************************************@spam yourself.com> wrote in message news:<40*********************@news.xs4all.nl>...

Thank you very much, that worked.
Hi,

I am not sure if you can name your picture 1, 2, 3
I think that a name should start with a letter or underscore.

Try this:

function dostuff(picnumber) {
document.images["pic"+picnumber].src="somethingelse.pic";
}

with the link like this:

<img src="a.gif" name="pic1"> <a href="#" onclick="dostuff(1)"> 1 </a>
<img src="a.gif" name="pic2"> <a href="#" onclick="dostuff(2)"> 2 </a>
<img src="a.gif" name="pic3"> <a href="#" onclick="dostuff(3)"> 3 </a>
Good luck,
Erwin Moller

Jul 20 '05 #3
Matthew Snape wrote:
Thank you very much, that worked.

Glad to help. :-)
Jul 20 '05 #4

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

Similar topics

3
by: joe | last post by:
Hello: I am using IIS 5.0, ASP and VBScript. I am puzzled by recurrences of errors when I nest subroutines, and I'd like to know if there are rules for that which I don't know. Would functions...
7
by: Microsoft | last post by:
I'm not sure where to physically place my subroutines in vb.net I get namespace and not declared errors... Imports System Imports System.Management Public Class Form1
3
by: OpticTygre | last post by:
I have a class, ProcessFiles, with several subroutines it runs for each type of file I want to "process." First, I check directories for files. Then, based on the filenames of those I find in...
5
by: Victor | last post by:
In ASP, if I define a subroutine as private Private Sub mySubroutine(arg1, arg2) I understand that the variables I define inside the subroutine are local only to the subroutine. If the same...
1
by: Wijaya Edward | last post by:
Hi, How does one benchmark multiple subroutines in Python? Is there a built-in library for that? -- Regards, Edward WIJAYA SINGAPORE
1
by: hanhaner | last post by:
hey, there I am new to Python and C++. Now I am trying to call some fortran subroutines in python code. I was told the good way is to write a c++ interface. I am not quite sure how to do it. ...
0
by: hanhaner | last post by:
hey, there I am new to Python and C++. Now I am trying to call some fortran subroutines in python code. I was told the good way is to write a c++ interface. I am not quite sure how to do it. ...
5
compman9902
by: compman9902 | last post by:
Hello, and thank you for viewing this thread. I was just wondering if there was a way to have subroutines, like in BASIC, in C++ that can use all of the same variables that main() does.
0
by: bbasberg | last post by:
Hello, First of all, I'm very sorry i mistakenly posted this message to the "articles" forum rather than this one and am unable to erase it from there. I apologize for the cross-posting. ...
10
by: liz0001 | last post by:
Hi, I need to access an .asp subroutine file from a subdomain. i.e. the website is at www.domain.com and I want to access the same subroutines on the subdomain mobile.domain.com. The...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.