473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

javascript popup and php variables - possible?

155 100+
I'm using this javascript:
[PHP]<script type='text/javascript' language='JavaScript'>
function PopUp(url) {
remote=window.open(url,'PopUpWindow','height=500,w idth=500,top=50,left=200,alwaysLowered=0,alwaysRai sed=0,channelmode=0,dependent=1,directories=0,full screen=0,hotkeys=0,location=0,menubar=0,resizable= 0,scrollbars=yes,status=0,titlebar=0,toolbar=0,z-lock=33');
if (!remote.opener)
remote.opener = self;
if (window.focus)
remote.focus();
}
</script>[/PHP]

And in the web page:
[PHP]echo '
<tr><td width="25%" align="right" valign="top">

<a href="javascript:popImage('http://www.mysite.com/gallery/<?php echo "$image_name"; ?>', '<?php echo "$item_title"; ?>')"><img src="gallery/thumbs/$image_name" width="$thumb_w" height="$thumb_h" alt="$item_title"></a></td>

<td width="1%">&nbsp;</td>
<td width="74%" valign="top"><u><strong>$item_title</strong></u><br><br>$item_desc</td></tr>
<td colspan="3"><hr></td></tr>
';[/PHP]

Is it possible to use a javascript popup window to display pictures using php variables? The ' and " seem to get things screwed up. You can use backslashes in the javascript code because it fails. The above just prints out $item_title and $item_desc on the web page and the thumbnail doesn't even show at all.
Oct 15 '07 #1
3 3013
pbmods
5,821 Expert 4TB
Heya, David.

Try this:
Expand|Select|Wrap|Line Numbers
  1. echo <<<END
  2. <tr><td width="25%" align="right" valign="top">
  3.  
  4. <a href="javascript:popImage('http://www.mysite.com/gallery/{$image_name}', '{$item_title}')"><img src="gallery/thumbs/{$image_name}" width="{$thumb_w}" height="{$thumb_h}" alt="{$item_title}"></a></td>
  5.  
  6. <td width="1%">&nbsp;</td>
  7. <td width="74%" valign="top"><u><strong>$item_title</strong></u><br><br>{$item_desc}</td></tr>
  8. <td colspan="3"><hr></td></tr>
  9. END;
  10.  
The curly braces are optional, but I like to use them to make the variables stand out a bit more.

http://php.net/manual/en/language.ty...syntax.heredoc
Oct 15 '07 #2
DavidPr
155 100+
It returned a javascript error "Object expected"

Line: 1
Char: 1
Oct 15 '07 #3
ak1dnar
1,584 Expert 1GB
It returned a javascript error "Object expected"

Line: 1
Char: 1
Check the function names again. in the JS it's popUp but you are trying to call it as popImage.
Oct 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jay | last post by:
Hi everybody !! I am just wondering if Javascript and PHP can interact with each other ? Let's say i have a variable in Javascript ( call it "var x = 6;") Is there anyway that we can use "x"...
2
by: Jeannie | last post by:
I have a popup window which is a slideshow of about 7 images. When the popup window loads, the first image is present and then the viewer can select next or previous to scroll through the rest of...
5
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore...
5
by: Connie Walsh | last post by:
Hi: I gleaned a javascript off of the web: http://www.hypergurl.com/popup.html that sets a cookie everytime someone visits your site. If it is the first visit in x number of days then a...
19
by: Stimp | last post by:
preferably one that when clicked can update three date dropdowns (day, month, year) like http://www.visitdublin.com/carhire/avis.asp Don't mind paying for the file... anyone seen something...
6
by: szabelin | last post by:
Hello, I am trying to call a function inside the javascript block from asp.net during the postback (NOT button's OnClick event handler though). The javascript function creates new popup window. I...
4
by: Erland | last post by:
Hello everyone, I am have couple of bad concepts and would like to clear things up. As I understand ASP.NET server controls contain runat=server tag and they only run on the server. But I've...
16
by: mktgmaker | last post by:
We are looking for a Javascript Programmer who is able to create a "onmouseover" popup similar to the one used by kontera.com (see contenlink link on the home page). The popup shall be transparent...
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.