Note that there are some explanatory texts on larger screens.

plurals
  1. POClearing input text field on enter or search button?
    primarykey
    data
    text
    <p>I've got a form that lets my user search. I'm using jQuery to append the search results lower in the page without reloading the page. So, I've got this:</p> <pre><code>isbn.php: &lt;form method="post" action="ajax.php" name="searchISBN" id="searchForm"&gt; &lt;input type="text" name="isbn" placeholder="Search..." /&gt; &lt;input class="myaccount" id="doSearch" name="doSearch" type="submit" value="Search" /&gt; &lt;/form&gt; </code></pre> <p>The problem is, I need that input text search field to clear when the user hits the Search button or hits enter. Both hitting enter and the Search button execute the search, so it must clear when either action happens.</p> <p>But, I'm absolutely stumped. </p> <p>Any help will be greatly appreciated!!</p> <p><strong>Edit:</strong> I've tried what Treffynnon suggested. The problem there is, I've disabled the search button from actually loading ajax.php. So, when I use that code, it stops the page from staying on isbn.php and it loads ajax.php . This is the code that loads the search results.</p> <pre><code>isbn.php: &lt;script&gt; // attach a submit handler to the form $("#searchForm").submit(function(event) { // stop form from submitting normally event.preventDefault(); // get some values from elements on the page: var $form = $( this ), term = $form.find( 'input[name="isbn"]' ).val(), //term = "isbn", url = $form.attr( 'action' ); $.post( url, { doSearch: "Search", isbn: term } , function( data ) { var content = $( data ); $( "#result" ).append( content ); } ); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload