Page 2 of 2

Posted: Wed Jun 09, 2004 3:58 am
by Dark-Rival
This is the code you just posted

Posted: Wed Jun 09, 2004 4:03 am
by feyd
no, it isn't. This needs to be inside php tags

Code: Select all

<?php
// you'll this next line
echo <<<STOP 
<script language="Javascript"> 
<!-- 
window1 = window.open('test.asp?id={$choice1}', '', 'scrollbars=yes,width=175,height=300'); 
window1 = window.open('test.asp?id={$choice2}', '', 'scrollbars=yes,width=175,height=300'); 
//--> 
</script> 
STOP;
// and the previous line
?>

Posted: Wed Jun 09, 2004 4:16 am
by Dark-Rival
All of the lines give parse errors now

Posted: Wed Jun 09, 2004 5:20 am
by Dark-Rival
This doesn't work either :(

Code: Select all

<?php 
// you'll this next line 
echo "<html><head>";
echo("<<<STOP");
echo("<script language="Javascript">");
echo("<!--"); 
echo("window1 = window.open('test.asp?id={$choice1}', '', 'scrollbars=yes,width=175,height=300');");
echo("window1 = window.open('test.asp?id={$choice2}', '', 'scrollbars=yes,width=175,height=300');");
echo("//-->");
echo("</script>");
echo("STOP;"); 
echo "</head><body>";
// and the previous line 
echo "</body></html>";
?>

Posted: Wed Jun 09, 2004 6:18 am
by feyd
ok... if you have an entire script like this, what do you see when you click the link?

Code: Select all

<?php

$choice1 = 16;
$choice2 = 24;

if(empty($_GET))
{
echo <<<STOP
<html>
	<head>
		<title>feyd's stab</title>
		<script language="Javascript"><!--

			var window1 = null;
			var window2 = null;
			
			function openSaysMe()
			{
				window1 = window.open('$_SERVER[SCRIPT_NAME]?id=$choice1', 'window1', 'scrollbars=yes,width=250,height=500');
				window2 = window.open('$_SERVER[SCRIPT_NAME]?id=$choice2', 'window2', 'scrollbars=yes,width=175,height=300');

				return false;
			}
			
			function closeSaysMe()
			{
				if(window1 != null)
					window1.close();

				if(window2 != null)
					window2.close();
				
				return false;
			}
			
		//--></script>
	</head>
	<body>
		<div align=center><table height="99%"><tr><td valign="middle"><a href="#" onclick="openSaysMe()">attempt to open two popups!</a><br /><a href="#" onclick="closeSaysMe()">attempt to close the two popups!</a></td></tr></table></div>
	</body>
</html>
STOP;
}
else
{
	header("Content-type: text/plain");
	print_r($_GET);
}

?>

Posted: Wed Jun 09, 2004 6:34 am
by feyd
note: on copying the code, you may need to remove some additional space(s) that may be at the ends of lines 8 and 51, otherwise you will get parsing errors.

Posted: Thu Jun 10, 2004 2:46 am
by Dark-Rival
feyd, thanks for all of your help, it is finally working now. However, there still is one problem (after this I'm never combining javascript with php again :))

The code looks like this now for those of you who are interested, it isn't exactly the way you explained it feys, but I've made this with your help:

Code: Select all

//Here is the javascript part inplented with php
echo("<script language="JavaScript">");
echo("function open_popup(page)");
echo("{");
echo("window.open('test2.php?id={$quarantineid}', '', 'scrollbars=yes,width=175,height=300');");
echo("return false;");
echo("}");
echo("open_popup('test2.php');");
echo("</script>");
echo "<a href="approvemail.php?id=$quarantineid" onclick="open_popup()"><font color="#131560">Approve</font></a></td>";
As you can see, there is just one pop up now, but I changed the script so that the main window can change to one of the pages, and the 2nd page will be the pop-up.

The problem here is that the $quarantineid in the javascript part will only fetch the last entry of the table. For example, I have a table with 20 entries. At the end of each entry you can click 'Approve mail'. Each of these mails has a seperate ID, and the approvemail.php link will get the proper id, but the javascript part (test2.php) will always fetch the last ID that has been entered no matter where I click.

So darn, can anybody help me with this :roll:

Posted: Thu Jun 10, 2004 8:46 am
by Dark-Rival
Ok well, it is working now with some major improvising, however still a problem! :evil: This window will pop-up ones one of the 2 pages that has to open opened:

Code: Select all

<?
global $id;
$quarid = $id;

$blah = "9";
echo("<script type="text/javascript">");

echo("if ({$blah} < 10) ");
echo("{");
echo("window.open('test2.php?id={$quarid}', '', 'scrollbars=yes,width=175,height=300');");
echo("}");
echo("else");
echo("{");
echo("document.write("Good day!")");
echo("}");
echo("</script>");
?>
I had to improvise with the action since I tried about everything. This works like a charm using my apache server. But ones I upload it to the IIS driven webserver (with php installed of course) it won't work! It will give the following error:
(message window)
A Runtime Error has occurred.
Do you wish to Debug?

Line: 0
Error: Syntax error

It can't define what line it is because it is inplented in php, the normal javascript version does work (without the php stuff) but then I can't send trough that darn variable.

Please help me, thanks.

Posted: Thu Jun 10, 2004 9:51 am
by feyd
hmm, very odd.