M
Matthew Snape
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?
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?