SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What would this function be called?

    Hi Guys,

    On my website I have this page:

    http://www.slougheaz.org/greenock/news_test/test.php

    Now at the bottom you will see an add pic section. When you hit select this launches a Javascript pop-up where you can search for an image.

    Now If you search for the word caption two results are returned. These two results as images have a <a href> tag around them.

    Now what I want to do is when either of the images are clicked on the image is moved/copied to the first page where the blank image is on the page.

    Can anyone advise what this type of function would be called in Javascript so I can do a search on how to achieve the above?

    Many Thanks

    Chris

  2. #2
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello first post

    try something like: <a href="#" onclick="window.opener.photopreview1.src=this.src">

    u mite need to give the image holder on the main page an id as well

    nb: i havent tested it tho it shuld work

  3. #3
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but confused:

    So Here’s the name of the image on my frontpage:

    HTML Code:
     <IMG NAME="photopreview1" BORDER="0" WIDTH="32" HEIGHT="32">
    And on my search results page I generate the following:

    PHP Code:
     echo '<a href="http://www.slougheaz.org/greenock/thumbnail/pics/'$rows['thumb_name'] .'"" onclick="window.opener.photopreview1.src=this.src"><img src="http://www.slougheaz.org/greenock/thumbnail/pics/'$rows['thumb_name'] .'"></a><br><br>'
    ...But it does not post/copy the image from the results page when clicked on into

    HTML Code:
     <IMG NAME="photopreview1" BORDER="0" WIDTH="32" HEIGHT="32">
    Any ideas?

    Thanks

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your onclick event is part of the <a> tag, so when you refer to this.src - there isn't one.

    Try
    onclick="window.opener.photopreview1.src=this.getElementsByTagName('img')[0].src"

  5. #5
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - not great with Javascript - so you mean:

    HTML Code:
    echo '<a href="http://www.slougheaz.org/greenock/thumbnail/pics/'. $rows['thumb_name'] .'"" onclick="window.opener.photopreview1.src=this.getElementsByTagName('img')[0].src"><img src="http://www.slougheaz.org/greenock/thumbnail/pics/'. $rows['thumb_name'] .'"></a><br><br>';
    As that throws up an error expecting ',' or ';'?

    Many Thanks

  6. #6
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Guys,

    Solved the above problem, but if you go to:

    http://www.slougheaz.org/greenock/news_test/test.php

    ...And you do a search on caption when you select one of the pictures is posting the image in the same window.

    How do I get it to copy/move it into the main page where the <img> is held? I thought by calling the image photopreview1 it would do this?

    Many Thanks

    Chris

  7. #7
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks jim
    thats what i meant

    i think ull fix the problem if u make the image tag:
    HTML Code:
    <img name="photopreview1" id="photopreview1" border="0" width="32px" height="32px">
    The alternative is to replace:
    HTML Code:
    window.opener.photopreview1.src
    with:
    HTML Code:
    window.opener.document.photopreview1.src
    or something like that

    hopefully that'll work


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
  •