Opening 2 links with 1 click
Moderator: General Moderators
- Dark-Rival
- Forum Newbie
- Posts: 21
- Joined: Thu Apr 15, 2004 5:03 am
- Location: Amsterdam
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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
?>- Dark-Rival
- Forum Newbie
- Posts: 21
- Joined: Thu Apr 15, 2004 5:03 am
- Location: Amsterdam
- Dark-Rival
- Forum Newbie
- Posts: 21
- Joined: Thu Apr 15, 2004 5:03 am
- Location: Amsterdam
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>";
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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);
}
?>- Dark-Rival
- Forum Newbie
- Posts: 21
- Joined: Thu Apr 15, 2004 5:03 am
- Location: Amsterdam
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:
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
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>";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
- Dark-Rival
- Forum Newbie
- Posts: 21
- Joined: Thu Apr 15, 2004 5:03 am
- Location: Amsterdam
Ok well, it is working now with some major improvising, however still a problem!
This window will pop-up ones one of the 2 pages that has to open opened:
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.
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>");
?>(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.