Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Javascript popup window. What am I missing?

Javascript popup window. What am I missing?

Locked

Views: 1,842

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
8 Dec 2010, 7:10 PM
#1
rovinghouse avatar

rovinghouse

New Zenner

Join Date:
Dec 2010
Posts:
13
Plugin Contributions:
0

Javascript popup window. What am I missing?

I'm using 1.3.9, have successfully installed Stocks by Attributes and Product Attribute Grid. Here's a sample page:

http://www.therovinghouse.com/store/index.php?main_page=product_info&cPath=1&products_id=6

Trying to make the attribute images that normally show up at the bottom of the grid work like the main image, with a popup window. However, when I add my code, it simply makes the images disappear. I can't figure out what I'm missing.

Here's the original PHP code within attributes.php that displays the images correctly:

	  if (zen_not_null($grid_records['H']['options'][$grh]['image'])) 
          {
	    $attrib_grid .= zen_image(DIR_WS_IMAGES . $grid_records['H']['options'][$grh]['image'], '', '75%', '75%');
	  }

Here's my code:

	  if (zen_not_null($grid_records['H']['options'][$grh]['image'])) 
          {

            $attrib_grid .= '<script language="javascript" type="text/javascript">';

            $attrib_grid .= '<!-- document.write';
            $attrib_grid .= '(\'<a href="javascript:popupWindow';
            $attrib_grid .= '(\\\'http://www.therovinghouse.com/store/index.php?main_page=popup_image';
            $attrib_grid .= '&pID='.$grh.'\\\')">';

            $attrib_grid .= zen_image(DIR_WS_IMAGES . $grid_records['H']['options'][$grh]['image'], '', '75%', '75%');
            $attrib_grid .= '</a>\'); //--></script>';
	  }

When I view the source of the finished page from the browser:
**
works (main image):**

<script language="javascript" type="text/javascript"><!--
document.write('<a href="javascript:popupWindow(\'http://www.therovinghouse.com/store/index.php?main_page=popup_image&pID=6\')">
<img src="images/feelnopain-lavender.jpg" alt="Women\'s \"Vegetables Feel No Pain\" T-shirt" title=" Women\'s \"Vegetables Feel No 

Pain\" T-shirt " width="108" height="120" /><br /><span class="imgLink">larger image</span></a>'); //--></script>

doesn't work (attributes images):

<script language="javascript" type="text/javascript"><!-- 
document.write('<a href="javascript:popupWindow(\'http://www.therovinghouse.com/store/index.php?main_page=popup_image&pID=2\')">
<img src="images/attributes/feelnopain-lavender.jpg" alt="" width="68" height="75" /></a>'); //--></script>

Thanks in advance.

8 Dec 2010, 9:59 PM
#2
rovinghouse avatar

rovinghouse

New Zenner

Join Date:
Dec 2010
Posts:
13
Plugin Contributions:
0

Re: Javascript popup window. What am I missing?

Ugh, I got it, for whatever reason the javascript needed a line break to work.

	  if (zen_not_null($grid_records['H']['options'][$grh]['image'])) 
          {
	    $attrib_grid .= '<script language="javascript" type="text/javascript"><!--';

	    $attrib_grid .= "\n";

            $attrib_grid .= 'document.write(\'<a 

href="javascript:popupWindow(\\\'http://www.therovinghouse.com/store/index.php?main_page=popup_image&pID='.$grh.'\\\')">';

	    $attrib_grid .= zen_image(DIR_WS_IMAGES . $grid_records['H']['options'][$grh]['image'], '', '75%', '75%');
	    $attrib_grid .= '</a>\'); //--></script>';
	  }
9 Dec 2010, 6:06 PM
#4
rovinghouse avatar

rovinghouse

New Zenner

Join Date:
Dec 2010
Posts:
13
Plugin Contributions:
0

Re: Javascript popup window. What am I missing?

bump. Only looking for help with the problem in the third post now. anyone?