PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Search Box Behavior - automatically clear the content

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search Box Behavior - automatically clear the content

    I have my search box in one frame and my results displayed in another frame. Everything is working well except that we I have done a search and I try to click back on the search box to try a different search I have to click on the first letter and then delete the word from the previous search. Is there a way to automaticly clear the contents in the search box and refresh it?

  • #2
    These past posts might help,
    Can I have "enter search term here" appear in search box?
    Way to clear search input box after submitting search

    Comment


    • #3
      I tried this code to clear the submit box and that part works but in my results page I get the message: No search query entered. I'm sure I missed something but not sure what. Thank you for any help.


      <script language="javascript">
      function cleartext()
      {
      document.form1.zoom_query.value = "";
      }
      </script>
      <form name="form1" action="../Zoom_Search/search.asp" target="MainContentFrame" onSubmit="cleartext();">
      <input type="text" name="zoom_query" size="13" value="">
      <input type="submit" value="Search">
      </form>

      Comment


      • #4
        Seems like a flaw in that original concept. It might be better changing the submit button and adding an onClick function.

        e.g.

        Code:
        <script language="javascript"> 
        function submitandclearsearch() 
        { 
        document.form1.submit();
        document.form1.zoom_query.value = "";
        } 
        </script> 
        <form name="form1" action="../Zoom_Search/search.asp" target="MainContentFrame">
        <input type="text" name="zoom_query" size="13" value="">
        <input type="button" value="Search" onclick="submitandclearsearch();">
        </form>
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Ray, thank you for your help. This new code works much better as long as you click on the submit with the mouse instead of just hitting ENTER.

          Comment


          • #6
            Ah. So demanding

            Code:
            <script language="javascript"> 
            function submitandclearsearch() 
            { 
            document.form1.submit();
            document.form1.zoom_query.value = "";
            } 
            </script> 
            <form name="form1" action="../Zoom_Search/search.asp" target="MainContentFrame">
            <input type="text" name="zoom_query" size="13" value="" onkeydown="if (event.keyCode == 13) document.getElementById('zoomSearchButton').click();">
            <input type="button" value="Search" id="zoomSearchButton" onclick="submitandclearsearch();">
            </form>
            Adjust to taste.
            --Ray
            Wrensoft Web Software
            Sydney, Australia
            Zoom Search Engine

            Comment

            Working...
            X