SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The same rollover image multiple times?

    ive got this rollover image:

    http://www.mykearmstrong.com/test/remove.html

    I need a ton of these on this one page, but whenever I duplicate the rollover image, none of them will work anymore:

    http://www.mykearmstrong.com/test/remove2.html

    Is there any way to have one script that will handle the same rollover image multiple times?

  2. #2
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give both images a different name:

    <A HREF="#" ONMOUSEOVER="changeImages('remove_01', 'images/remove_01-over.gif'); return true;" ONMOUSEOUT="changeImages('remove_01', 'images/remove_01.gif'); return true;"><IMG NAME="remove_01" SRC="images/remove_01.gif" WIDTH=30 HEIGHT=16 BORDER=0 ALT=""></A>

    <A HREF="#" ONMOUSEOVER="changeImages('remove_02', 'images/remove_01-over.gif'); return true;" ONMOUSEOUT="changeImages('remove_02', 'images/remove_01.gif'); return true;"><IMG NAME="remove_02" SRC="images/remove_01.gif" WIDTH=30 HEIGHT=16 BORDER=0 ALT=""></A>

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the red X is going to appear next to items from a search.. there could be 1 there could be 25, so I need to be able to include the same exact script for each red X, I cant change the names...

  4. #4
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course you can.

    How are you pulling out the search results? PHP, Perl, ASP, ...?

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im using php, users can search and add to the list, and then search some more and add to the list, and then click the little red x to remove their items from the list.

  6. #6
    SitePoint Addict
    Join Date
    May 2003
    Location
    The Netherlands
    Posts
    391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So you are looping through some results before you present them to the visitors, right?

    It would be helpful if you post a link to the page where all this is hapenning, but anyway, suppose the JavaScript function that swaps the images looks like this:

    <script language="JavaScript">
    <!--
    function swap(image){
    var src="images/remove_01.gif";
    var src_over="images/remove_01-over.gif";
    // I'm of course supposing, as you did, that the images are always the same
    var theImage=eval("document."+image);
    if (theImage.src==src){theImage.src=src_over;}
    else {theImage.src=src;}
    return true;
    }

    Now suppose your results array to look like this:

    @results=array($result1,$result2, ... ,$resultn);

    To print them on the page you could use a simple for loop like:

    $theResultString="";
    for ($i=1;$i<=sizeof(@results);$i++){
    $theResultString.='<A HREF="#" ONMOUSEOVER="swap($i);" ONMOUSEOUT="swap($i);"><IMG NAME="$i" SRC="images/remove_01.gif" WIDTH=30 HEIGHT=16 BORDER=0 ALT=""></A> $results[($i-1)]';
    }
    echo $theResultString;


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
  •