Click to See Complete Forum and Search --> : [RESOLVED] Picture Swapping


sniper
07-20-2006, 07:33 AM
I'm working on this website for this company that will allow them to book meetings for there conference rooms. On this site I have a details page that allows the users to see all the details of the room. I have multiple pictures of the room on this page and have it displaying as one large picture and the rest are smaller and set up like tabs. What I want to happen is, when a user clicks on one the smaller pictures it will swap places with the big one. I have the smaller pics as imagebuttons to get the click event. Any help, tips, or links would be greatly appreciated.

fvillena
07-20-2006, 08:02 AM
You can do this through Javascript

Firstly the javascript

<script language="JavaScript">
<!--
function changeimg(imgpath)
{
imgprop.src = imgpath;
}
// -->
</script>

Then the image link

<img src="img/defaultimage.gif" name="imgprop" vspace="2" id="imgprop">

Change defaultimage.gif with the image you want displayed when the page first loads

Finally the links to change the image

<a href='javascript:changeimg("img/imageone.gif")'>First Image</a>
<a href='javascript:changeimg("img/imagetwo.gif")'>Second Image</a>
<a href='javascript:changeimg("img/imagethree.gif")'>Third Image</a>...

sniper
07-20-2006, 11:57 AM
Is there a way to do it in .NET with the code behind?

sniper
07-25-2006, 09:24 AM
Does anyone know a way to do this in asp.net (vb) 1.1. The way I have this set up is one main image and four smaller image buttons. When I click any of the image buttons, it should switch with the main image. All the image urls are taken out of a database. The code I have will only swap once, so I end up losing a pic. I will post the code I have right now.


Private Sub Image1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Image1.Click
Dim large As String
Dim small As String

large = imgLarge.ImageUrl '''main image
small = Image1.ImageUrl '''image button one

If Page.IsPostBack Then
If Image1.ImageUrl = large Then
Image1.ImageUrl = small
imgLarge.ImageUrl = large
Else
Image1.ImageUrl = large
imgLarge.ImageUrl = small
End If
End If
End Sub


All help will be appreciated.