Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to Highlight choose image?

    hi
    i have 10 pictures...
    i want when the user click on image this image will have red border...
    and if he will click on diffrent picture it will have red border and the last image will not have the red border
    how pleaes?
    have a nice day !!!

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Make an array of the images, loop through the array and set all to clear border, then make the selected image have a red border.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #3
    New Coder
    Join Date
    Jul 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WolfShade View Post
    Make an array of the images, loop through the array and set all to clear border, then make the selected image have a red border.
    I maked array
    but i dont know how to clear border and after that to make the selected image have a red border

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Pass the image ID as a parameter to the function.
    Code:
    for(var i=0; i<arrayName.length; i++){
      arrayName[i].style.border = "1px solid white";
    }
    document.getElementById(imageID).style.border = "1px solid red";
    This is pseudo code, of course.. you'll need to change and enter information as it pertains to your page.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #5
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,915
    Thanks
    56
    Thanked 545 Times in 542 Posts
    possibly simpler...

    Code:
    <head>
    <style>
    img {
    height:200px;
    width:200px;
    border:5px solid black;
    }
    </style>
    </head>
    <body>
    <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Points_of_a_horse.jpg/330px-Points_of_a_horse.jpg" onclick="changeBor(this)"/>
    <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/9/98/Horse-and-pony.jpg/310px-Horse-and-pony.jpg" onclick="changeBor(this)"/>
    <script>
    var changed;
    function changeBor(pic){
    if (changed){changed.style.borderColor="black";}
    pic.style.borderColor="red";
    changed=pic;
    }
    </script>
    </body>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •