Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP & Java script - Rollover Photo Change

    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?

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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:

    Code:
    <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:

    Code:
    <% 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.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    New Coder
    Join Date
    Jul 2007
    Location
    North Carolina, US
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I have an idea, but post the code for the large image and the thumbnails or all of the code if you want.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •