Page 1 of 1

How to make a popup window with a textarea.

Posted: Mon Apr 04, 2011 7:32 pm
by mikeglaz
I have this page:
http://www.mikeglaz.com/wujek/manage.php?location=art
When you click on 'View' it displays the enlarged image in a popup window.
In the database for these pics I have the following columns: id, name, description.

What I want to be able to do is display a popup window with a textarea and the description of the pic within it when I click on 'Edit'. I want to be able to modify the text and save it.

Here's the code for 'View' within manage.php:

Code: Select all

echo "<a href=\"javascript:create_window('$path',$image_size[0],$image_size[1])\">
		<span class=\"imageText\">View</span></a>";

where $path is the path to the picture

then create_window looks like this:

Code: Select all

	function create_window (image, width, height) 
	{
	
		// Add some pixels to the width and height:
		width = width + 20;
		height = height + 20;
		
		// If the window is already open, 
		// resize it to the new dimensions:
		if (window.popup && !window.popup.closed) {
			window.popup.resizeTo(width, height);
		} 
		
		// Set the window properties:
		var specs = "location=no, scrollbars=no, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=" + width + ", height=" + height;
		
		// Set the URL:
		var url = "show_image.php?image=" + image;
		
		// Create the pop-up window:
		popup = window.open(url, "ImageWindow", specs);
		popup.focus();
		
	} // End of function.
Finally showimage.php looks like this:

Code: Select all

<?php # Script 10.5 - show_image.php
// This page displays an image.

$name = FALSE; // Flag variable:

// Check for an image name in the URL:
if (isset($_GET['image'])) {
	// Full image path:
	$image = "{$_GET['image']}";

	// Check that the image exists and is a file:
	if (file_exists ($image) && (is_file($image))) 
{
		// Set the name as this image:
		$name = $_GET['image'];
		
	} // End of file_exists() IF.
	
} // End of isset($_GET['image']) IF.


// Get the image information:
$info = getimagesize($image);
$fs = filesize($image);

// Send the content information:

header ("Content-Type: {$info['mime']}\n");
header ("Content-Disposition: inline; filename=\"$name\"\n");
header ("Content-Length: $fs\n");

// Send the file:
readfile ($image);	
?>
I've been trying to modify these to display a textarea but I don't know what goes in the header content.

Re: How to make a popup window with a textarea.

Posted: Mon Apr 04, 2011 8:29 pm
by mikeglaz
Ok, I'm slowly getting there. My question now is how do I return information entered into the textarea of a popup back to the calling page?