Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

swapping images

Status
Not open for further replies.

peterific

Programmer
Apr 19, 2002
1
IE
I need to change an image without changing anything else on the page from say image1.jpg to image2.jpg an it has to be done in VBScript. I can do it in Javascript but for some reason I can't get it working in VBscript.

Thanks for any help
 
Here is a code snippet that works for me.
Put the code into an HTML file and get two images in the same directory.

<Script Language=&quot;VBScript&quot;>

Function ChangeImg(theField)
if instr(1,theField.src,&quot;printer.gif&quot;) <>0 then
theField.src=&quot;email.gif&quot;
else
theField.src=&quot;printer.gif&quot;
end if
End function
</script>


<img name=&quot;picprinter&quot; src=&quot;printer.gif&quot; onclick='ChangeImg(document.all(&quot;picprinter&quot;))'>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top