Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending to a popup

Status
Not open for further replies.

purcion

Programmer
Feb 14, 2005
32
AU
I have listed some code I m working on that works well
basically it pulls some data off a database and limits it to displaying 250 characters of the description which if the user clicks on the ..more link it will pass the variable onto a new page and show them the whole description if it is larger that 250 chars.
Im trying to get this data dispalyed to a popup window and what ever I try Im getting un expected Tstring errors the
change needs to be made in the $s4 variable but i cant get it to work I have tried things like this for example just to even see if I can use a popup without even trying to pass the $GLOBAL[''];
example of what i tried

$s4 = '<a href="javascript: window.open('file.php', 'window_name', 'width = 50, height = 50')">..More</a>';
This is giving me T_String errors
below is the code Im using currently .
If some one can help me make $s4 a popup I would really apreciate it .
Thanks again

Code :

=========================================================


<?php
function nicetrim ($s) {
$MAX_LENGTH = 250;
$Str = html_entity_decode($s);
if (strlen($Str) <= $MAX_LENGTH) {
return $s;
}
$s2 = substr($Str, 0, $MAX_LENGTH - 3);
$s3 = '......';
$s4 = '<a href="['description'].'" ><font color="#000000">
More</font></a>';
return htmlentities($s2).$s3.$s4;
}

?>
// this works and is called in the html like so

<div align="left">'.nicetrim ($description).'
</div>

//to make it a popup is what i need
=============================================

Thanks
 
I think the way ur calling a function is causing a problem.

If u want to call the function from HTML code try this

<div align="left"><?php nicetrim ($description); ?></div>


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Thanks, but i dont have a problem calling the function at all
my problem is getting the output into a popup window I can pass the output to a normal page no problems but it seems again it comes down to syntax, javascript and php have some differences the reason im using GLOBALS is because Im making a query outside of the function so to make the data usable in the function which works fine .. this is sort of what i am resorting to to get what i want achieved
and its ugly , because i dont understand java enough
its creating a full sized copy underneath as well as the popup on top ,but if someone
understands whats going on below then mabye they can make it a more elgeant solution because im simply just trying to pass the variables via a link to a single popup window.
========================================================
$s4 = "<a href=\"['description']."\" onclick=\"window.open(this.href, 'popupwindow', 'height=500,width=655,scrollbars,resizable'); \">..More </a>";
======================================================
thanks again
 
If i am getting u correctly u want to pass id which is in $GLOBALS['description'] and pass it to url " while opening a popup window..?


Code:
$url = "[URL unfurl="true"]http://www.address.org/return.php?id=".$GLOBALS[/URL]['description'] ;
$s4 =  "<a href=\"javascript:void(0)\" onclick=javascript:window.open('$url','popupwindow','height=500,width=655,scrollbars,resizable')>..More </a>";

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
hey thanks I had trouble with the code you posted it threw some T_variable errors the best I was able to do which did work was
======================================================
$s4 = "<a href=\"['description']."\" onclick=\"window.open(this.href, 'popupwindow', 'height=500,width=655,scrollbars,resizable');return false; \">More </a>";
=======================================================
which is fairly close to what you are saying, I originally wanted to use a javascript function that makes the popup center of screen ect but I just found it to hard to use it in php . THe function below
=====================================================
<script LANGUAGE="JavaScript">
function popUp(URL,popW,popH) {
var w = 480, h = 340;
if (document.all || document.layers) {
w = screen.availWidth;
h = screen.availHeight;
}
var topPos = (h-popH)/2, leftPos = (w-popW)/2;
window.open(URL,'popup','resizable, toolbar=no, location=no, status=no, scrollbars=no, menubar=no, titlebar=no, width=' + popW + ',height=' + popH + ',left=' + leftPos + ',top=' + topPos + ',screenX=' + leftPos + ',screenY=' + topPos);
}
// -->
</script>
<!-- End -->
//this is how it is called when i try to put that into a php variable I have all sorts of problems

<a HREF="JavaScript:popUp('popup.htm',470,590)">Click here</a>

=========================================================
but
I do have popups going now I would really like to know if it is possible to use this javascript and how ,so I can control where they open
not up in top right left corner but in the centre of the screen..
======================================================
thanks for having a go spookie .
 
Yes u can very well control the position of popup on screen by using screenX and screenY.

eg:
Code:
$s4 =  "<a href=\"[URL unfurl="true"]http://www.adresss/return2.php?id=".$GLOBALS[/URL]['description']."\" onclick=\"window.open(this.href, 'popupwindow', 'height=500,width=655,screenX=400,screenY=300,scrollbars,resizable');return false; \">More </a>";

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Just hit the submit button too early.

screenX attribute - This allows a new window to be created at a specified number of pixels from the left side of the screen, in above case its 400
screenY attribute - This allows a new window to be created at a specified number of pixels from the top of the screen, in above case its 300.


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top