Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:45+00:00 2026-06-04T16:08:45+00:00

First off I am completely new to Javascript but I have some HTML/CSS experience.

  • 0

First off I am completely new to Javascript but I have some HTML/CSS experience. I’ve been trying to create an html/javascript image gallery for a website; (It would probably be a lot easier to do in PHP but the web coordinator disabled PHP on our server for security reasons).

Anyway What I have is a page showing an Album-list, Album-browser and Photo-viewer in different a div and 2 iframes respectively. I have it set up so that when someone clicks on an album from the album list, a page is opened up in the album browser section (iframe:”browser-frame” showing thumbnails of all the images in the particular album). I’ve been trying to set it up so that when someone clicks on an image in the album browser the image will appear in the Photo-viewer section (iframe:”viewer-frame” showing the photo itself).

I didn’t want the photo’s in the viewer-frame to be larger than the set dimensions for the viewer-frame so I created a page for the viewer-frame that puts the image in a div with a class of set dimensions (defined in a stylesheet) as follows:

...<body>
<div class="photoview">
<img id="viewed_image" class="large" src="images/album1/1.jpg" />              
</div>
</body>...

I then created a script that updates the image src to a variable:image_to_be_viewed and called it image-changer.js

// JavaScript Document
{
var image_to_be_viewed="images/album1/1.jpg";
document.getElementById("viewed_image").src=image_to_be_viewed;
}

And added a script to the viewer-frame page so it looks like:

...<body>
<div class="photoview">
<img id="viewed_image" class="large" src="images/album1/1.jpg" />
<script src="image-changer.js"></script>              
</div>
</body>...

Now I wanted the gallery to work so that in the page loaded in the browser-frame, whenever one clicked on one of the pictures, the value of the global variable ‘image_to_be_viewed’ would be changed to the source of the clicked image as follows:

<body>
<div class="photobrowse">
        <img class="medium" src="images/album1/1.jpg" onClick="image_to_be_viewed='images/album1/1.jpg'"/>
        <img class="medium" src="images/album1/2.jpg" onClick="image_to_be_viewed='images/album1/2.jpg'"/>
        <img class="medium" src="images/album1/3.jpg" onClick="image_to_be_viewed='images/album1/3.jpg'"/>
</div>
</body>

It doesn’t work….

the gallery i’m working on is on http://ptc.tamu.edu/test/gallery_directory/test_gallery.html
everything up to the loading of the selected picture in the viewer frame works (I’m running the onlick event on the default loaded pictures 1,2,3 in the browser-frame page)(default pic’s 4 and 5 simply load the image in the iframe but with no way to adjust the size it is too big and gets cut off and i don’t want that)

I’ve been working on for an entire day and I’m sure I’m doing something wrong here but I can’t figure out what exactly it is. I have a feeling it has to do with changing the global variable: image_to_be_viewed from the browser-frame page but I wanted to confirm with experts instead of flopping about like a headless fish. I’m going to continue trying to figure this out but i thought maybe having some expert assistance would speed up the process.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:08:46+00:00Added an answer on June 4, 2026 at 4:08 pm

    What the onclick triggers should be a javascript function call.

    e.g. onclick="changeImg('images/album1/1.jpg')"

    And the function itself should looks like this

    function changeImg (image_to_be_viewed) {
      document.getElementById("viewed_image").src = image_to_be_viewed;
    }
    

    btw, you probably should learn javascript a little bit more before work on something real. I recommend this book

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I'm completely new to Drupal, so I could be making a ridiculously
First off I'm new to owning an android and trying to develop android apps.
First off, I am completely new to iOS development, so I hope there is
First off, let me clarify the platforms we are using. We have an ASP.NET
First off, let me start by saying that I am totally new to working
First off, I am not a DBA, but I do work in an environment
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and
First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
First off, I'm aware this is a bad practice and I have answered many
I think I may have asked this on Haskell-Cafe at some point, but damned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.