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 6739013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:26:13+00:00 2026-05-26T11:26:13+00:00

Here ‘s the test site. I’m using a Javascript onClick event function to dynamically

  • 0

Here‘s the test site.

I’m using a Javascript onClick event function to dynamically change the src of the displayed full-size image. However, this isn’t quite working the same way in changing the width of the div that contains the image. I have tested that the function is actually getting the given width and it is, so it’s probably just not defining the width value of my div correctly.

<?php
$username = $_GET['username'];
session_start();
$_SESSION['username'] = $username;

//Database Information
$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpass = "";

//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect:         ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

//Do the query
$query = mysql_query("SELECT * FROM images ORDER BY idnum DESC LIMIT 5");

//Generate an array of all images
$images = array();
while($image = mysql_fetch_array($query)) {
//this adds each image to the images array
$images[] = $image;
$image['filename'] = $firstimage;
}
?>

<?php

// Beginning attempt at a caption script.



?>

<html>
<head>
<title>Home - Site in Development</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
 <script type="text/javascript">

 // Switches the url to view large image.

   function switchImageUrl(url, width) {
    document.getElementById('img-frame').src = url;
    document.GetElementById('center_frame').offsetwidth = width;

   }

 </script>



</head>
<body onLoad="CalculateAllImageWidthes()">
<div id='account_links'>
  <?php
  if ($_SESSION['username']) {
    echo "Welcome $username!";
  } else { ?>
    <a href='login.php'>Login</a> | <a href='register.php'>Register</a>
  <?php } ?>
   </div>

<h1>Picture Captions</h1>
<br/>
<br/>
<div id="left_bar">
  Submit a picture <a href="upload.php">here</a>.
<hr/>
<h2>Top Images</h2>
<br/>

<div id="front_pg_images">
  <?php foreach($images as $image) { ?>
    <a href="#" onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>')"><img src="<?php echo $image['filename'];?>" width="72px" height="58px" id="front_pg_thumbnail"/></a>
    <?php echo $image['name']." - by ".$image['submitter']; ?> <br/>
    <br/>
  <?php } ?>
 </div>
 </div>
 <div id="center_frame" width="<?php echo $image['width']; ?>">
  <img src="<?php echo $image['filename'];?>" name="default" id="img-frame" align="left" valign="top">
</div>

  • 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-05-26T11:26:14+00:00Added an answer on May 26, 2026 at 11:26 am

    This is the problematic line:

    document.GetElementById('center_frame').offsetwidth = width;
    
    1. the correct name of the method is getElementById – JavaScript is case-sensitive
    2. replace offsetwidth (which should have been offsetWidth anyway) with style.width
    3. replace width with width + 'px'

    so your line looks like:

    document.getElementById('center_frame').style.width = width + 'px';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my test function (c#, visual studio 2010): [TestMethod()] public void TestGetRelevantWeeks() { List<sbyte>
Here is my little test image: http://imageshack.us/photo/my-images/851/testnb.jpg/ Basically they are two images, as you
Here's my simple first attempt at a python extension using boost. Can someone help
Here is a snippet of my JavaScript Code that I want to DRY up:
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,

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.