SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Thread: New Window Size

  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    New Window Size

    I have a line up Php code below

    Code:
    echo"<form name=sub method=post target=_blank
    >> action=\"$hm2/addrating.php\">";
    I want to specify the width and height of the new window. How can this be done? I could do it with plain javascipt but then my php wont work and need to somehow combine the 2 which is beyond me.

    Thanks!

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to use JavaScript to define the width/height of the new window

  3. #3
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realise that but had trouble integrating the javascript code with the Php.

    Could someone please tell me what the code should be.

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look window.open up and you should be all set

  5. #5
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So something like

    Code:
    window.open( [$hm2/addrating.php\] [,_blank] [,height=300 width=300] )
    If correct where should that go in the php

    Code:
    echo"window.open( [$hm2/addrating.php\] [,_blank] [,height=300 width=300] )";
    It doesnt work so must be wrong. Please correct.

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be easier to help you if you would write her what is outputted in the HTML instead of showing PHP code.

    Show was the actual HTML/JavaScript looks like

  7. #7
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <style>
    .star{cursor:pointer; }
    
    </style>
    
    <script language=javascript>
    	var name = new Array();
    	name[0]= "<?php echo($hm2);?>/images/star2.gif";
    	if(document.images)
    	{
    		var ss = new Image();
    		ss.src = name[0];		
    	}			
    
    function selstar(rr,val)
    {
    	var x = rr;
    	for(var y=1;y<=val;y++)
    	{
    		document[x+'.'+y].src="<?php echo "$hm2";?>/images/star2.gif";
    	}
    	
    }
    function remstar(rr,val)
    {
    	var x =rr;
    	for(var y=1;y<=val;y++)
    	{
    		document[x+'.'+y].src="<?php echo "$hm2";?>/images/star1.gif";
    	}
    }
    
    function setrate(rr,val)
    {
    	document.sub.rating.value =val;
    	document.sub.uid.value =rr;
    	document.sub.submit();
    }
    </script>
    
    <?php
    $uid = array();
    $rateval = array();
    $start = $_GET['begin'];
    if($start == "")
    	$start = 0;
    $url = $_SERVER['SCRIPT_NAME'];
    $host = $_SERVER['SERVER_NAME'];
    $ser = "http://$host";
    $url1 = $_SERVER['argv'];
    $sss = count($url1);
    $rip = $_SERVER['REMOTE_ADDR'];
    if($sss >= 1)
    {
     $argas = $url1[0];
     $url="$url?$argas";
    }
    $url= $ser.$url;
    
    if(strpos($url,"?begin=")){
    	$url = substr($url,0,strpos($url,"?begin="));
    }else if(strpos($url,"&begin=")){
    	$url = substr($url,0,strpos($url,"&begin="));
    }
    
    include "$hm/auth/config.php";
    
    $link = mysql_connect($hostname, $username,$password);
    if($link)
    {
    	$dbcon = mysql_select_db($dbname,$link);
    }
    
    //echo "$url";
    $quer = @mysql_query("select uid,avg(rateval) from rating where url='$url' group by uid",$link);
    while($line1= @mysql_fetch_array($quer, MYSQL_BOTH))
    {
    	$uid[] = $line1[0];
    	$rateval[] = $line1[1];     
    }
    
    $qur = "select * from colors";
    $result = mysql_query($qur,$link);
    if($line = @mysql_fetch_array($result, MYSQL_ASSOC))
    {
    	$border = $line['border'];
    	$bmessage = $line['bmessage'];
    	$bgcolor = $line['bgcolor'];
    	$messagebg = $line['messagebg'];
    	$message = $line['message'];
    	$infobg = $line['infobg'];
    	$info = $line['info'];
    	$others = $line['others'];
    }
    if($border == "")
    	$border= "green";
    if($bmessage== "")
    	$bmessage = "white";
    if($bgcolor== "")
    	$bgcolor = "#ccffcc";
    if($messagebg== "")
    	$messagebg = "#dddddd";
    if($message == "")
    	$message = "#333333";
    if($infobg == "")
    	$infobg = "#ddffee";
    if($info == "")
    	$info = "#0000dd";
    if($others == "")
    	$others = "#343434";
    
    
    function showrate($id,$hm2,$uid,$rateval) //function to add a rating dialog
    {
    	//echo "$uid[0],$uid[1],$rateval[0],$rateval[1]";
    	$flaga = "true";
    	$j = $id;
    	echo"<table cellpadding=0 cellspacing=0 border=0 style=\"border: 0px solid green;font-family: arial, verdana, san-serif; font-size: 13px;\">";
    	echo("<tr align=center><td>");
    	echo "<form name=rate$j>";
    	echo"<input type=hidden name=uid value=$j>";
    	echo "<b>Shop Rating: </b>";
    	$x = count($uid);
    	//echo ("count---$x");
    	for($a=0;$a<$x;$a++)
    	{
    		if($uid[$a]==$id)
    		{	
    			
    			$flaga= "false";
    			//echo "$rateval[$a]";
    			for($i=1;$i<=5;$i++)
    			{
    				//echo "$hm2";
    				if($rateval[$a]>=1)
    				{
    					echo "<img src=\"$hm2/images/star2.gif\">";
    					$rateval[$a]=$rateval[$a]-1;
    				}
    				else if($rateval[$a]>=0.5)
    				{
    					echo "<img src=\"$hm2/images/star3.gif\">";
    					$rateval[$a]=$rateval[$a]-1;
    				}
    				else if($rateval[$a]<0.5 && $rateval[$a]>0)
    				{
    					echo "<img src=\"$hm2/images/star3.gif\">";
    					$rateval[$a]=$rateval[$a]-1;
    				}
    				else if($rateval[$a]<=0)
    				{
    					echo "<img src=\"$hm2/images/star1.gif\">";
    				}			
    			}//end for
    		} // end if
           } // end for
    	if($flaga=="true")
    	{
    		for($i=1;$i<=5;$i++)
    		{
    			echo "<img src=\"$hm2/images/star1.gif\">";
    		}
    	}
    	echo"</td></tr>";
    	echo"<tr><td align=center>";
    	echo"<b>Rate this Shop :</b>";
    	echo"<img name=$j.1  class=star onmouseover=\"selstar($j,1)\" onmouseout=\"remstar($j,1)\" 	onclick=\"setrate($j,1)\" src=$hm2/images/star1.gif>";
    	echo"<img name=$j.2 class=star onmouseover=\"selstar($j,2)\" onmouseout=\"remstar($j,2)\" onclick=\"setrate($j,2)\" src=$hm2/images/star1.gif>";
    	echo"<img name=$j.3 class=star onmouseover=\"selstar($j,3)\" onmouseout=\"remstar($j,3)\" onclick=\"setrate($j,3)\" src=$hm2/images/star1.gif>";
    	echo"<img name=$j.4 class=star onmouseover=\"selstar($j,4)\" onmouseout=\"remstar($j,4)\" onclick=\"setrate($j,4)\" src=$hm2/images/star1.gif>";
    	echo"<img name=$j.5 class=star onmouseover=\"selstar($j,5)\" onmouseout=\"remstar($j,5)\" onclick=\"setrate($j,5)\" src=$hm2/images/star1.gif>";
    	echo "</form>";
    	//echo"&nbsp;&nbsp; <a onClick=\"show()\" href=$PHP_SELF?begin=0 style=\"font-family:aerial;font-size:	15px; color:#bb1515;text-decoration:none;\">View/Add Comments</a>;
    	echo "</td></tr></table>";
    
    }
    
    echo"<form name=sub method=post target=_blank
    action=\"$hm2/addrating.php\">";
    echo"<input type=hidden name=rating>";
    echo"<input type=hidden name=uid>";
    echo"<input type=hidden value=$url name=url>";
    echo"<input type=hidden value=$rip name=ip>";
    echo"</form>";
    
    ?>

  8. #8
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Again, including all that PHP code to show what you want to achieve doesn't really help.

    Anyway, you want to submit to a popup you defined the height and width, try this:
    Code:
    <script type="text/javascript">
    function submitToPopup()
    {
    	window.open("about:blank", "myPopup", "width=200,height=200");
    	document.forms[0].submit();
    }
    </script>
    
    <form action="results.php" target="myPopup" onsubmit="submitToPopup(); return false;">
    	<input type="text">
    	<input type="submit">
    </form>

  9. #9
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've put the first bit at the top of the page, and the rest as below.

    Code:
    echo"<form action="$hm2/addrating.php\" target="myPopup" onsubmit="submitToPopup(); return false;">
    <input type="text"><input type="submit"></form>";
    echo"<input type=hidden name=rating>";
    echo"<input type=hidden name=uid>";
    echo"<input type=hidden value=$url name=url>";
    echo"<input type=hidden value=$rip name=ip>";
    echo"</form>";
    Now I get the message: Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/ed/public_html/HRS/addcode.php on line 188.

    188 being the first line of the above.

  10. #10
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, that is because you need to escape the quotes...

    The PHP string is broken now, use backslash to escape quotes. This is the same for all programming languages. Check out the php string documentation for this.

  11. #11
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I put double backslash at the beginning like this

    Code:
    //echo"<form action="$hm2/addrating.php\" target="myPopup" onsubmit="submitToPopup(); return false;"><input type="text"><input type="submit"></form>";
    The page now displays fine but it doesnt do anything. It should open a new confirmation window when a rating is given (when the form is submitted).

    Take a look http://www.e-discounts.co.uk/index2.php?CID=47

  12. #12
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check the JavaScript console in Firefox, it will tell you that document.sub is undefined

  13. #13
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And the solution to this problem is?

  14. #14
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it can't find document.sub, go figure!

  15. #15
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A google search has shed no light on the issue.

    I understand that you're trying to make me do something myself, and not rely on other people. However I wouldnt be asking if I didnt need help, and I have made an effort but really do need some advice.

  16. #16
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Usually when you get a "document.something has no properties" it means that it cannot find the element.

    What is document.sub suppose to be? A form? There is no form named "sub".

  17. #17
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll look into it (ask the guy that coded it for me)

    It worked before I did this popup thing, so surely its effected it somehow. Therefore he's not going to be able to help much as he didnt write the popup bit.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •