Need some help here. I have a main page index.php with a simple js function, say function1() which upon clicking, opens a page, say test.php as a pop-up window, which includes contents from another page p1.php. I need to condition it so that when user clicks function2(), it opens same page test.php but with different content from page p2.php.
index.php code is below;
<script language="JavaScript" type="text/JavaScript">
<!--
function function1(theURL,winName,features) {
window.open(theURL,winName,features);
}
//-->
<!--
function function2(theURL,winName,features) {
window.open(theURL,winName,features);
}
//-->
</script>
<td>
<p><a href="#" class="left-content" onclick="function1('test.php','','scrollbars=yes,width=auto,height=600')">Page 1 contents</a></p>
</td>
<td>
<p><a href="#" class="left-content" onclick="function2('test.php','','scrollbars=yes,width=auto,height=600')">Page 2 contents</a></p>
</td>
I am making the following conditional statements in page test.php
<?php
$a = include ("p1.php");
$b = include ("p2.php");
if(isset($_GET['<script>function1()</script>']))
echo $a;
else if(isset($_GET['<script>function2()</script>']))
echo $b;
?>
The result I get is that the contents of both p1.php and p2.php are reflecting in test.php (our pop-up window). How do I condition it so that only p1.php content is reflected onclicking function1() and p2.php content is reflected onclicking functions2(). Any help is appreciated.
function1andfunction2even defined? - By the way, I'm surprised you get either p1.php or p2.php with that PHP code, seeing as both those conditions would never be true