SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    Tennessee
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile clear IE filter from form img's

    Hey all i am trying to figure out a way to clear my 120+ images that are inside my form. I can do this right now by using the following code:
    Code:
    onmouseup="this.style.filter='';"
    However, that has to be present for every image and i really would like to clear them all (since it seems sometimes the filter stays on the image even if i release my mouse button. This will allow for it to clear even if i hit another image since it will be looping though all of them.

    Is there any way to mod this code that i found to look for the '<img' tag within the form and clear them all in a loop?
    Code:
    <script type="text/javascript">
    function clearFilter(){
    for( var elem, i = 0; ( elem = document.test.elements[i] ); i++ )
    {
    	elem.style.filter='';
    }
    }
    </script>
    
    <form name="test">
    <input type="text" value="" /></p>
    <div align="center"><img src="file:///c:/images/ButtonU.png" alt="" width="100" height="100" onClick="clearFilter();" onmousedown="this.style.filter='progid:DXImageTransform.Microsoft.BasicImage(XRay=1)'; " onmouseup="this.style.filter='';" /><bR>
    <br>
    <input type="button" value="submit" name="submitButton">
    </div>
    </form>
    Thanks for your time,
    David

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe something like this:

    Code Javascript:
    var IMG = document.getElementById('test').getElementsByTagName('IMG');
    for( var i = 0 ; i < IMG.length ; ++i ) {
       IMG[i].onmouseup=function(){
           this.style.filter='';
       }
    }
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    Tennessee
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    JimmyP: Thanks for the reply!

    However, i dont think that is what i was looking for. It seems to do the same thing as if i had "this.style.filter='';" for each img (which i do currently). What i would like to do is loop through ALL the img tags and do the "this.style.filter='';" on them, not just us 'this' for that one img... i hope that makes more since...
    Code:
    function clearFilter(){
    var img = document.getElementById('test').getElementsByTagName('img');
    for( var i = 0 ; i < img.length ; ++i )
    {
       img[i].onmouseup=function()
        {
           this.style.filter='';
        }
    }
    }
    This is what i was thinking...
    Code:
    function clearFilter(){
    var img = document.getElementById('test').getElementsByTagName('img');
    for( var i = 0 ; i < img.length ; ++i )
    {
       //do until i = Last Img tag.
       img[i].onmouseup=function()
        {
           img[i].style.filter='';
           ++i
        }
       //loop
    }
    }
    David

  4. #4
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh... okay.

    So, when any image within "test" form is clicked on, you want all images to be affected... right?

    Something like this? -

    Code Javascript:
    var IMG = document.getElementById('test').getElementsByTagName('IMG');
    for( var i = 0 ; i < IMG.length ; ++i ) {
       IMG[i].onmouseup=function(){
           for( var x = 0 ; x < IMG.length ; ++x ) {
               IMG[x].style.filter='';
           }
       }
    }
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    Tennessee
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep JimmyP that did it!

    Thank you very much

    David


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
  •