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 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clearing text from a search box . . .

    I have a search box on my website and I finally got it working correctly with help from VIPStephan. But, there is one problem. After clicking search the box doesn't remove the entered text. I have tried a few things with no luck. Was hoping someone could give me a clue. The code for the search box is here, thanks
    JD in KC http://kcHamRadio.com
    </tr>
    <td class="tcat">Callsign Lookup:</td>
    <tr bgcolor="F4EBD5">
    <td align="center">
    <!-- HamCall Callsign Lookup Blank START -->
    <form method="POST" action="http://hamcall.net/call/ "target="_blank">
    <div>
    <input size="12" name="callsign" style="font-size: 130%" maxlength="7" />
    <input type="submit" value="Search" />
    </div>
    </form><!-- HamCall Callsign Lookup Blank END -->

  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    I have this code from a previous Topic reply from VIPsteven (I think)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>js demo</title>
        <script type="text/javascript">
    window.onload = function() {
        if (document.getElementById("inp_search")) {
        var s = document.getElementById("search");
        var v = s.defaultValue;
        s.onfocus = function() {if(s.value==v) s.value='';}
        s.onblur= function() {if(s.value=='') s.value=v;}
        }
        }
        </script>
       
      </head>
      <body>
        <form action="">
          <input type="text" id="inp_search" name="search" value="Search...">
        </form>
      </body>
    </html>
    See if that works for you.


  •  

    Posting Permissions

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