Jump to content

outputting javascript array info


rudy507

Recommended Posts

Hey guys,

There's a little PHP here, but I think this is a javascript issue... I am creating a javascript array, and within a php while() loop, I am adding values to the array and then am trying to output the results. However, what I want outputted to the browser is not being sent.

 

I am trying to output an image, but it is not happening.

 

Any ideas why this is happening?

 

Edit: I cleaned up the code a little ...

<?PHP
/*
Author: David White
Date Started: 02/06/2007
Description: 	This script will allow a user to browse through pictures
	in a directory to select one picture. It will place all of the contents
	in a directory into an array which will be displayed one-by-one on the click
	of a button.
*/

// Set the Directory Location
$directory = opendir('../premier_images/');

// Put every picture in the directory into an array
echo "<script type=\"text/javascript\">
	var output = new Array()
	var i = 0;
";
while ($picture = readdir($directory)) {
echo " 	output[i] = " . $picture . "
	document.write('
		<div id='+output[i]+' style=\'<!-- display:none;-->align=center;valign=center;\'>
			<img src=\'../premier_images/'+output[i]+\'>
			<br />
		</div>
		');
	i++;
	document.write(i);
	";
}
echo "</script><br /><br /><input type='button' value='Next Photo' onClick=\"next_photo_gallery('".current($output)."', '".next($output)."')\">";
?>

Link to comment
Share on other sites

Are you suggesting to assign my variable in document.write()?

 

If you are, I didn't think that this was possible... I thought that document.write() is supposed to print out actual text in the browser.

 

If the other way, you are telling me NOT to do this, I'm already not doing this... unless you see something I don't see.

 

Thanks for the response.

 

- David

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.