Page 1 of 1

php and javascript

Posted: Tue May 31, 2005 6:19 pm
by ddragas
cannot figure it out.

what am i doing wrong?

I want to pass wariable to pop-up window and to open pop-up window resized on width and height of image

Code: Select all

<a href="Untitled-2.php" onClick="return popitup('Untitled-2.php')">Link to popup</a>
write with php


If I write it in this way it doesnt open pop-up

Code: Select all

<?

echo  '<a href="Untitled-2.php?slika='.urlencode($image_to_convert) .'"';
echo 'onClick="return popitup("Untitled-2.php")">Pošalji poruku vlasniku</a>';
?>
Here is complete code



Code: Select all

<?php  

$image_to_convert = "../resize/zaglavlje.jpg";//$_GET['filename'];

$the_image_path = $image_to_convert;
$file_type = strtolower(strrchr($the_image_path,"."));


switch ($file_type) {
case ".JPEG":

    	$slika1 = imagecreatefromjpeg($image_to_convert);
   break;
case ".JPG":

    	$slika1 = imagecreatefromjpeg($image_to_convert);
   break;
case ".jpeg":

    	$slika1 = imagecreatefromjpeg($image_to_convert);
   break;
case ".jpg":

    	$slika1 = imagecreatefromjpeg($image_to_convert);
   break;
case ".PNG":

    	$slika1 = imagecreatefrompng($image_to_convert);
   break;
case ".png":

    	$slika1 = imagecreatefrompng($image_to_convert);
   break;
}


$slika = $image_to_convert;//"../watermark/DSCF3127.JPG"; //original picture

$size = getimagesize($slika); 
    $width = $size[0];
    $height = $size[1];

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function popitup(url)
{
newwindow=window.open(url,'name','height=<? echo $height; ?>,width=<? echo $width; ?>');
if (window.focus) {newwindow.focus()}
return false;
}

// -->
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title></title>
</head>

<body>
<p>
<a href="Untitled-2.php" onClick="return popitup('Untitled-2.php')">Link to popup</a>
</p>
<?

echo  '<a href="Untitled-2.php?slika='.urlencode($image_to_convert) .'"';
echo 'onClick="return popitup("Untitled-2.php")">Pošalji poruku vlasniku</a>';
?>
</body>
</html>

Posted: Tue May 31, 2005 7:06 pm
by Skara

Code: Select all

onClick=&quote;return popitup(&quote;Untitled-2.php&quote;)&quote;
You can't embed the same type of quote like that. onClick is getting "return popitup(" and that's it. Change it to this:

Code: Select all

echo 'onClick="return popitup(\'Untitled-2.php\')">Pošalji poruku vlasniku</a>';

Posted: Wed Jun 01, 2005 2:28 am
by ddragas
Thank you for help