user type london record fetch from data base and show below the input field
<input type="text" id="inputSuccess" name="name" onkeyup="autosearch(this.value)" > //user type london
when user click on london than london add in input field but it cannot set in input field what jquery script require to select the value from p tag and show in input field
<script>
function autosearch(name){
//get data from database
$.ajax({
url:"ajax.php",
type:'post',
data: {name: name},
success:function(result){
$('.result').html(result);
}
});
}
</script>
ajax.php
<div style="border: 1px solid #ccc;width:100%;" >
<a href="javascript:void(0)">
</div>
<div>
<p><?php echo $data['cityName']; ?> </p> //london show here
</div>
</a>
</div>