SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Wales
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to construct a JS line in PHP, problem...

    Hi All,

    I'm trying to construct a simple Javascript line (used in a swap image) using PHP. Here it is:

    PHP Code:
    <a href="javascript:;" onclick="MM_swapImage('bigimage','','<?php $this->absolute_path 'images/large/' $vehicle['int_main'];?>',1)">
    So this, I'd hoped, would fill in the value of the image to be swapped with from a DB call earlier on.

    The contructed line looks like this:
    PHP Code:
    <a href="javascript;:" onclick="MM_swapImage('bigimage','','',1)"
    It should look like this:
    PHP Code:
    <a href="javascript;:" onclick="MM_swapImage('bigimage','','images/large/dsc_3647.jpg',1)"
    I know $this->absolute_path . 'images/large/' . $vehicle['int_main'] produces the right code (an image name) and the JS swap image works but simply inserts a blank because there's no image to swap with i.e. it is missing in the JS line? I'm all out of ideas now, anyone offer some insight?

    Many thanks

    Rob

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You're missing the word "echo" to tell it you want to output that variable.

    PHP Code:
    <a href="javascript:;" onclick="MM_swapImage('bigimage','','<?php echo $this->absolute_path 'images/large/' $vehicle['int_main'];?>',1)">

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Wales
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Such a simple error, sometimes I cannot see the wood for the trees!!!

    Thank you


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
  •