Results 1 to 5 of 5

Thread: How to clear the border color (preserving the existing one) ??

  1. #1
    Join Date
    May 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to clear the border color (preserving the existing one) ??

    Hello Forums !!
    I had following script for marking the fields with certain color border and clearing that color border , preserving the fields original border color.
    Code:
    <!-- Javascript -->
    <script language="javascript">
    function FMark(){
    	document.forms['frm_mark'].test_field.style.border = "1px solid #ff0000";  
    }
    
    function FClear(){
    	document.forms['frm_mark'].test_field.style.border = "none"; 
    }
    </script>
    <!-- HTML -->
    <form name="frm_mark" action="#" method="get">
    <input type="text" name="test_field" style="border: 1px solid #0066FF" />
    <input type="button" value="Mark" onclick="FMark();"/>
    <input type="button" value="Clear" onclick="FClear();"/>
    </form>
    Whats my problem ?
    - I am able to mark the field but also able to clear that marked one but couldnt preserve the existing border color

    What I want ?
    - I want to clear the marked border color preserving the existing border color ie #0066FF
    Any Suggestion and Help are warmly welcome
    Thanks in advance to all of you

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    - I am able to mark the field but also able to clear that marked one but couldnt preserve the existing border color
    Because you set the border to "none", aka. no border.

    Try this:
    HTML Code:
    <!-- Javascript -->
    <script type="text/javascript">
    function FMark(){
    	document.forms['frm_mark'].elements['test_field'].style.border = "1px solid #ff0000";  
    }
    
    function FClear(){
    	document.forms['frm_mark'].elements['test_field'].style.border = "1px solid #0066FF"; 
    }
    </script>
    <!-- HTML -->
    <form name="frm_mark" action="#" method="get">
    <input type="text" name="test_field" style="border: 1px solid #0066FF">
    <input type="button" value="Mark" onclick="FMark();">
    <input type="button" value="Clear" onclick="FClear();">
    </form>
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    May 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks MR.tech_support for the reply.
    But one thing the color value is dynamic , its not fixed. so this method doesnt work..is there any alternatives
    Thanks again

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    What do you mean by dynamic? The colour will change in the style=""

    Just don't specify a border in the clearing, like this:
    Code:
    function FClear(){
    	document.forms['frm_mark'].elements['test_field'].style.border = ""; 
    }
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    May 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    WooHooo
    Thanks Mr. tech_support
    that really rocked ...

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
  •