...

View Full Version : ASP & Java script - Rollover Photo Change



johnplank
08-17-2007, 12:55 PM
Help, I am a bit stuck with a problem.

I want to achieve the following.

We have a website written in ASP. Many of the pages are generated out of a database. These pages contain, amongst other information the names of images to be displayed (up to 6 per page).

The images are to be displayed as thumbnails with one of the also displayed as a larger image. When we rollover the thumbs we want the larger image to change accordingly.

How do we use the image names that are read out of the database with the ASP code to work with javascript functions? :confused: :confused:

Daemonspyre
08-17-2007, 03:29 PM
You can mix JS and ASP together easily, as long as you follow 2 simple rules:

1) If you know your JS before hand, make sure that the variables are in JS and the data is ASP.

EXAMPLE:



<script language="javascript">
function testMe() {
var test = '<%= session("var_from_db") %>';
}
</script>



2) If you don't know how your ASP will interact with JS, then use ASP to write the JS for you.

EXAMPLE:



<% response.write("<script language=""javascript"">" & vbCrLf)
response.write("function testMe() {" & vbCrLf)
'
for each i in session.contents
response.write(" var " & i & " = '" & session(i) & "';" & vbCrLf)
next
'
response.write("</script>" & vbCrLf) %>


This is just example code and won't work, but it does give you an example of how you can populate JS with ASP variables.

nbcrockett
08-17-2007, 03:29 PM
I have an idea, but post the code for the large image and the thumbnails or all of the code if you want.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum