I'm retrieving data on keyup
from DB using the following script
<script>
$(function(){
$('.input').keyup(function(){
var a = $('.input').val();
$.post('actions/action_user_search.php',{"search":a},function(data){
//show results
$('#display').html(data);
});
});
});
</script>
I would like to display the result(s) as a list inside the textbox and not below the textbox
echo '<h1>Search User</h1>
<form action= "actions/action_user_search.php" method="POST" >
<input type="text" name="search" class="input">
</form>
<div id="display" style="margin-top:50px" ></div>';
How can I display the results in the textbox as a list and not using the way shown here (within the div id=display)
Thanks
You are using wrong selector. This code will set text to your textbox if the data
is a string:
$('input[name=search]').val(data);
If response data
is an HTML code, you have to parse it first, extract list items and then set to textbox
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.