SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Nr Leeds
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Onclick In PHP...

    Please take a look at the code below it is from OS Commerce.

    I would like to add java script so that on clicking the image they are taken to another page, I have tried lots of things but cannot seam to manage it.

    I would like the image to be clicked and taken to http://dev.uk-developments.co.uk/aff...card_popup.htm

    The location of the image is : http://dev.uk-developments.co.uk/aff...es/loyalty.jpg

    Code:
    <?php
    /*
      Card Infobox, v 1.0 2002/12/04 by Kevin Park
    
      osCommerce
      http://www.oscommerce.com/
    
      Copyright (c) 2000,2001 osCommerce
    
      Released under the GNU General Public License
    */
    
    
    
    
    
    ?>
    
    <!-- loyalty Info Box //-->
              <tr>
                <td>
                
                
                
            
               
    /* 
    
    <?php
      $info_box_contents = array();
    
      $info_box_contents = array();
      $info_box_contents[] = array('align' => 'center',
    
                                   'text'  => '<a href="' . tep_href_link("information.php?info_id=2") . '">' . tep_image(DIR_WS_TEMPLATE_IMAGES . 'loyalty.jpg', 'Loyalty Rewards') . '</a>'
                                   );
    
    new infoBox($info_box_contents);
    ?>
    
     */
    
    
    </td></tr>
    <!-- loyalty_eof //-->
    - Any help would be much appreciated, and if you could explain how its done that would be even better. I could do it simply just with an image and java script popup but i do not want to change the layout with the
    $info_box_contents variable as it may mess up the whole website being OS Commerce

    Thanks

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Do you mean open a popup onclick or send them to a different page entirely?
    And do you mean the image that has a link already attached to it...

    'text' => '<a href="' . tep_href_link("information.php?info_id=2") . '">'
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Nr Leeds
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    At present when the image is clicked you are taken to a new page containing info. Instead I would like when the image is clicked for a popup window to open displaying the information instead of going to a new page./

  4. #4
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Nr Leeds
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Only just noticed... Manchester aye spikeZ - Just a stones throw away, thanks the they help by the way

  5. #5
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Just over them hills

    Right then, this could either work or kill it.....!
    I dont use OSCommerce but I am hazarding a guess that tep_href_link() is a defined function for handling links.

    so first up a bit of javascript:

    Code JavaScript:
    <script type="text/javascript">
    var newwindow;
    function popit(url)
    {
    	newwindow=window.open(url,'name','height=400,width=200');
    	if (window.focus) {newwindow.focus()}
    }
    </script>

    followed by a little code change:

    Code PHP:
     'text'  => '<a href="javascript:;"  onclick="popit(\'information.php?info_id=2\');">' . tep_image(DIR_WS_TEMPLATE_IMAGES . 'loyalty.jpg', 'Loyalty Rewards') . '</a>'


    See what happens with that.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you have to escape the single quotes:
    Code php:
    'text'  => '<a href="javascript:;"  onclick="popit(\'information.php?info_id=2\');">' . tep_image(DIR_WS_TEMPLATE_IMAGES . 'loyalty.jpg', 'Loyalty Rewards') . '</a>'

    Wouldn't this simple one work for you?
    Code:
    <a href="javascript:void(null);" onClick="window.open('./product_info.php?product_id=12','','width=650,height=700;scrollbars=yes');">Product Info</a>
    Please make it suitable for your osCommerce linking code. I am not osCommerse user yet.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    Blimey Rajug, you must have been looking at the reply in the 3 seconds it took me to edit the post after I had noticed the single quotes too!

    Regarding the inline javascript, the reason I put it into a function is so that it could be reused if required, both options should work fine though.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    Nr Leeds
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Worked a treat, cheers love ! (Oh aye we're getting yorkshire now lass) :-)

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    153 Post(s)
    Tagged
    3 Thread(s)
    By 'eck chuck, tha thanks are all good but am nay a Lass.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •