1

I have text input and html form. where I put users name and submit to get their information. Now I have use ajax to show username.

<div class="hidesearch" id="search" style="width:"400px;">

                 <input type="text"  id="searchbox"  name="user_name" value=""/>
</div>

Problem is when I type text, it shows previous content I submitted in the auto complet options.

What I need is to override the values that shows in the auto-complete and render the names in the auto complete area from ajax call.

 function wpay_search() {
 // echo 'Sasi is  a t est';
    global $wpdb;
    $name=$_POST['user_name'];
    $employee=$wpdb->get_results("SELECT `First_Name` FROM table_list WHERE First_name LIKE '$name%' ");

    foreach($employee as $key=> $value){

     echo '<ul>';
     echo '<li>'.$value->First_Name;'</li>';
     echo '</ul>';
  //   echo $value->post_content;

   }


    //wp_reset_query();
    die();
} // end theme_custom_handler
add_action( 'wp_ajax_wpay_search', 'wpay_search' );
add_action( 'wp_ajax_nopriv_wpay_search', 'wpay_search' );
wordpressm
  • 3,189
  • 3
  • 20
  • 29

2 Answers2

1

You can use jQuery Autocomplete and set the attribute autocomplete to false on the input.

Community
  • 1
  • 1
Jeremy Gallant
  • 764
  • 3
  • 12
0

try autocomplete="off" on the input field like this:

<input type="text"  id="searchbox"  name="user_name" value="" autocomplete="off"/>

Or you can try not using an input field at all. I just use a div in my own Autocompleter.

ggouweloos
  • 26
  • 3
  • http://stackoverflow.com/questions/582244/is-there-a-w3c-valid-way-to-disable-autocomplete-in-a-html-form it says it is a nonstand atribut – wordpressm Jun 25 '13 at 13:20
  • 1
    It is valid in HTML5: [link](http://www.w3schools.com/tags/att_input_autocomplete.asp) – ggouweloos Jun 25 '13 at 17:58