Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-30-2012, 10:47 AM   PM User | #1
Dankid
New to the CF scene

 
Join Date: May 2012
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Dankid is an unknown quantity at this point
Opening windows from a PHP form

I am trying to open windows at the client using URLs I get from a mySQL database.
That is why I use a PHP form, but although the script is generated - windows don't open.
Can you help me how to make it work?

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script type="text/javascript">

        </script>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1255">
    <TITLE>Running Shoes Comparisons Open Windows</TITLE>
    <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1  (Win32)">
    <META NAME="CREATED" CONTENT="0;0">
    <META NAME="CHANGED" CONTENT="0;0">
    
    <STYLE TYPE="text/css">
    <!--
        P { text-align: center }
    -->
    </STYLE>
</HEAD>
<BODY LANG="zxx" DIR="LTR">
<div name="shoeframes"><p align=center>
<?php
         $ModelID
=$_GET["m"];
         
//echo $ModelID."<br>";
         
echo "Enjoy your shopping <br>" ;
        
//$test="<iframe src='http://www.wiggle.co.uk/mizuno-ladies-wave-alchemy-11-shoes/' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0'></iframe>";
        
    
mysql_connect("localhost","XX","YY");
    
mysql_select_db("runningshoes"); 
    
    
$s "SELECT * FROM `ShoeLinks` WHERE `ModelID` =" $ModelID ;
    
    
//echo $s."<br>";    
    
$sql mysql_query($s); 
    
$StoreLink 'StoreLink'
    
$PicLink'PicLink';
    
$i=0;
    global 
$st,$StoreLink,$PicLink,$Link,$rows;
    
//echo $test;
    
    
while ($rows mysql_fetch_assoc($sql)) 
    { global 
$i;
      
$i$i+1;
        
$Link=$rows[$StoreLink];
        
//echo "<br> StoreLink".$i.": ".$rows[$StoreLink];
        //echo $rows[$StoreLink].strlen($rows[$StoreLink])."<br>";
        
if (strlen($rows[$StoreLink])>9)
        {  
             
$st=substr($rows[$StoreLink],0,7);
             
//echo $st."<br>";
             
if ($st=="<iframe")
             {
                         
//echo "test"."<br>";
                          
echo $rows[$StoreLink];             
             } else
             {
                           
//echo "test2"."<br>";
                         
echo "<br><br><a href='".$rows[$StoreLink]."' target='_blank'><font face='Trebuchet MS' color='Red' size='5pt'>Press this link to buy at ".$rows['Store']."</font></a><br>";
                           echo 
"<iframe src='".$rows[$StoreLink]."' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0' ></iframe><br>";
             }
        } elseif (
strlen($rows[$PicLink])>9)
        {
                      
$st=substr($rows[$PicLink],0,7);
                      if (
$st=="<iframe")
                     {
                          echo 
$rows[$PicLink];             
                   } else
                {
                           echo 
"<iframe src='".$rows[$PicLink]."' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0' ></iframe>";
                }
        }

    
//echo "<a href='".$rows[$StoreLink]."' target='_blank' onclick='return Open_Win(this.href)'>Press</a>";
    
?>
    
    <script language="JavaScript" type="text/javascript">        
                    myWindow=window.open(<?php  echo "'".$rows[$StoreLink]."'"?>,'_blank','width=600,height=400');
                    myWindow.document.write("<p>This is 'myWindow'</p>");
                    myWindow.focus();
    </script>
 <?php  ?>

<!-- START of the zanox affiliate HTML code -->
<!-- ( The HTML code may not be changed in the sense of faultless functionality! ) -->

<img src="http://ad.zanox.com/ppv/?22275759C1259558066" align="bottom" width="1" height="1" border="0" hspace="1"><a href="http://ad.zanox.com/ppc/?22275759C1259558066T&ULP=[[XXX]]">Datafeed</a>

<!-- ENDING of the zanox-affiliate HTML-Code -->
</div>     
</BODY>
</HTML>
Dankid is offline   Reply With Quote
Old 07-30-2012, 04:23 PM   PM User | #2
c1lonewolf
Regular Coder

 
Join Date: Sep 2002
Posts: 216
Thanks: 0
Thanked 11 Times in 11 Posts
c1lonewolf is an unknown quantity at this point
Code:
    echo "<a href='#nogo'  onclick='Open_Win(".$rows[$StoreLink].");return false;'>Press</a>";
    ?>
    
    <script language="JavaScript" type="text/javascript">   
function Open_Win(lnk){     
                    myWindow=window.open(lnk, '', '_blank', 'width=600,height=400');
                    myWindow.document.write("<p>This is 'myWindow'</p>");
                    myWindow.focus();
}
    </script>
 <?php  } ?>
Try that...
__________________
NO Limits!!
c1lonewolf is offline   Reply With Quote
Old 07-30-2012, 11:28 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,247
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
This line is wrong:
Code:
    myWindow=window.open(lnk, '', '_blank', 'width=600,height=400');
It has too many arguments. window.open only takes 3, max.

It should be simply
Code:
    myWindow=window.open(lnk, '_blank', 'width=600,height=400');
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 07-31-2012, 01:06 PM   PM User | #4
Dankid
New to the CF scene

 
Join Date: May 2012
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Dankid is an unknown quantity at this point
I did all you suggested but still no windows is being opened.
See HTML:
Code:
<body marginwidth="0" marginheight="0">
<form>
<p align="center"><font face="Trebuchet MS" color="Red" size="3pt">
<br><b>Just Pick you shoe model</b></font><br><br>
Brand: <select name="choice1" onchange="updateChoice1(this);">
<option value="">-- choose --</option>
<option value="1"> Mizuno</option>
<option value="2"> Brooks</option>
<option value="3"> Zoot</option>
</select>
<br><br><br>
Type: <select name="Type" onchange="updateChoice1(this);">
<option value="Men"> Men's Running Shoes</option>
<option selected="selected" value="Women"> Women's Running Shoes</option>
<option value="Kids"> Kids' Running Shoes</option>
</select>
<br><br>
</p><div id="txtHint">



<title>Model</title>



<p align="center">Model: <select name="choice2" id="ModelIDchosen" onchange="updateChoice2(this)"><option value="1">Wave Alchemy 11</option><option value="2">Wave Ascend 6</option><option value="3">Wave Nirvana 8</option></select><br><br><br></p><p align="center"><input type="button" value="compare!" onclick="OpenWindows(this);"></p>


</div> 

<div id="ShoeFrames">


<script type="text/javascript">
function Open_Win(lnk)
{     
                    myWindow=window.open(lnk, '_blank', 'width=600,height=400');
                    myWindow.document.write("<p>This is 'myWindow'</p>");
                    myWindow.focus();
}
 
		</script>
	<meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1255">
	<title>Running Shoes Comparisons Open Windows</title>
	<meta name="GENERATOR" content="OpenOffice.org 3.1  (Win32)">
	<meta name="CREATED" content="0;0">
	<meta name="CHANGED" content="0;0">
	
	<style type="text/css">
	<!--
		P { text-align: center }
	-->
	</style>


<div name="shoeframes"><p align="center">
Enjoy your shopping <br><br><br><a href="http://www.runningwarehouse.com/descpageWRS-MAL11W1.html" target="_blank"><font face="Trebuchet MS" color="Red" size="5pt">Press this link to buy at RunningWarehouse</font></a><br><iframe src="http://www.runningwarehouse.com/descpageWRS-MAL11W1.html" style="width:600px;height:400px;" scrolling="yes" marginwidth="0" marginheight="0" frameborder="0"></iframe><br>	
	<script language="text/javascript" type="text/javascript">		
	Open_Win ('http://www.runningwarehouse.com/descpageWRS-MAL11W1.html');
					
	</script>
 <iframe src="http://www.wiggle.co.uk/mizuno-ladies-wave-alchemy-11-shoes/" style="width:80%;height:400px;" scrolling="yes" marginwidth="0" marginheight="0" frameborder="0"></iframe>	
	<script language="text/javascript" type="text/javascript">		
	Open_Win ('--');
					
	</script>
 
<!-- START of the zanox affiliate HTML code -->
<!-- ( The HTML code may not be changed in the sense of faultless functionality! ) -->

<img src="http://ad.zanox.com/ppv/?22275759C1259558066" align="bottom" width="1" height="1" border="0" hspace="1"><a href="http://ad.zanox.com/ppc/?22275759C1259558066T&amp;ULP=[[XXX]]">Datafeed</a>

<!-- ENDING of the zanox-affiliate HTML-Code -->
</p></div>	 


</div>
<br><br>
<input type="hidden" name="myBrand" readonly="" value="1"><br>
<input type="hidden" name="myType" readonly="" value="Women"><br>
<input type="hidden" name="myModel" readonly="" value=""><br>


</form>
<div style=" margin-left:33px; margin-top:29px; margin-right:15px; line-height:14px "><font face="Trebuchet MS">Copyright 2012 © Value-Focused Investments Ltd. All rights reserved. <span class="blue"><a href="#">Terms of use</a>&nbsp; |&nbsp; <a href="index-5.html">Privacy Policy</a>&nbsp; |&nbsp; <a href="http://www.ForRunnersByRunners.com?PartnerID=442" title=" Buy Running Shoes, Running Clothing &amp; More"><font color="#3a7197"><u>Running Shoes</u></font></a></span></font></div>
							

</body>
and the PHP code:
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script type="text/javascript">
function Open_Win(lnk)
{     
                    myWindow=window.open(lnk, '_blank', 'width=600,height=400');
                    myWindow.document.write("<p>This is 'myWindow'</p>");
                    myWindow.focus();
}
 
        </script>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1255">
    <TITLE>Running Shoes Comparisons Open Windows</TITLE>
    <META NAME="GENERATOR" CONTENT="OpenOffice.org 3.1  (Win32)">
    <META NAME="CREATED" CONTENT="0;0">
    <META NAME="CHANGED" CONTENT="0;0">
    
    <STYLE TYPE="text/css">
    <!--
        P { text-align: center }
    -->
    </STYLE>
</HEAD>
<BODY LANG="zxx" DIR="LTR">
<div name="shoeframes"><p align=center>
<?php
         $ModelID
=$_GET["m"];
         
//echo $ModelID."<br>";
         
echo "Enjoy your shopping <br>" ;
        
//$test="<iframe src='http://www.wiggle.co.uk/mizuno-ladies-wave-alchemy-11-shoes/' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0'></iframe>";
        
    
mysql_connect("localhost","X","Y");
    
mysql_select_db("runningshoes"); 
    
    
$s "SELECT * FROM `ShoeLinks` WHERE `ModelID` =" $ModelID ;
    
    
//echo $s."<br>";    
    
$sql mysql_query($s); 
    
$StoreLink 'StoreLink'
    
$PicLink'PicLink';
    
$i=0;
    global 
$st,$StoreLink,$PicLink,$Link,$rows;
    
//echo $test;
    
    
while ($rows mysql_fetch_assoc($sql)) 
    { global 
$i;
      
$i$i+1;
        
$Link=$rows[$StoreLink];
        
//echo "<br> StoreLink".$i.": ".$rows[$StoreLink];
        //echo $rows[$StoreLink].strlen($rows[$StoreLink])."<br>";
        
if (strlen($rows[$StoreLink])>9)
        {  
             
$st=substr($rows[$StoreLink],0,7);
             
//echo $st."<br>";
             
if ($st=="<iframe")
             {
                         
//echo "test"."<br>";
                          
echo $rows[$StoreLink];             
             } else
             {
                           
//echo "test2"."<br>";
                         
echo "<br><br><a href='".$rows[$StoreLink]."' target='_blank'><font face='Trebuchet MS' color='Red' size='5pt'>Press this link to buy at ".$rows['Store']."</font></a><br>";
                           echo 
"<iframe src='".$rows[$StoreLink]."' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0' ></iframe><br>";
             }
        } elseif (
strlen($rows[$PicLink])>9)
        {
                      
$st=substr($rows[$PicLink],0,7);
                      if (
$st=="<iframe")
                     {
                          echo 
$rows[$PicLink];             
                   } else
                {
                           echo 
"<iframe src='".$rows[$PicLink]."' style='width:600px;height:400px;' scrolling='yes' marginwidth='0' marginheight='0' frameborder='0' ></iframe>";
                }
        }

    
//echo "<a href='".$rows[$StoreLink]."' target='_blank' onclick='return Open_Win(this.href)'>Press</a>";
    
?>
    
    <script language="text/javascript" type="text/javascript">        
    Open_Win (<?php  echo "'".$rows[$StoreLink]."'"?>);
                    
    </script>
 <?php  ?>

<!-- START of the zanox affiliate HTML code -->
<!-- ( The HTML code may not be changed in the sense of faultless functionality! ) -->

<img src="http://ad.zanox.com/ppv/?22275759C1259558066" align="bottom" width="1" height="1" border="0" hspace="1"><a href="http://ad.zanox.com/ppc/?22275759C1259558066T&ULP=[[XXX]]">Datafeed</a>

<!-- ENDING of the zanox-affiliate HTML-Code -->
</div>     
</BODY>
</HTML>
Dankid is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, php, window.open

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:27 AM.


Advertisement
Log in to turn off these ads.