rudy507 Posted February 10, 2007 Share Posted February 10, 2007 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 https://forums.phpfreaks.com/topic/37855-outputting-javascript-array-info/ Share on other sites More sharing options...
fenway Posted February 10, 2007 Share Posted February 10, 2007 Variable assignment & document.write() together? Link to comment https://forums.phpfreaks.com/topic/37855-outputting-javascript-array-info/#findComment-181226 Share on other sites More sharing options...
rudy507 Posted February 10, 2007 Author Share Posted February 10, 2007 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 https://forums.phpfreaks.com/topic/37855-outputting-javascript-array-info/#findComment-181263 Share on other sites More sharing options...
fenway Posted February 10, 2007 Share Posted February 10, 2007 I'm probably just confused about the code structure. Link to comment https://forums.phpfreaks.com/topic/37855-outputting-javascript-array-info/#findComment-181297 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.