I would like to assign input box field value as a php variable in a same page when any keypress/keyup event is happen. The input box is as following,
<input type="search" id="searchbox" class="inputbox-findtag" name="keyword" placeholder="Search tag...">
I would like to assign the input box field value with live(i.e, on keyup/keypress/...) as a php variable in a same page that is look like,
$field_value = [input box value]
To do this I have already used jQuery-Ajax that is look like below,
$("#searchbox").on('keyup',function () {
var key = $(this).val();
$.ajax({
url:'fetch.php',
type:'GET',
data:'keyword='+key,
success:function (data) {
$("#rsql").html(data);
}
});
});
And the fetch.php file is below,
if($_GET['keyword'] && !empty($_GET['keyword']))
{
$keyword = $_GET['keyword'];
echo $keyword;
}
I have already got the input box value by keyup. But how can I assign this value as a php variable $field_value that I have declared previous.
If you have any other idea to get live input box field value in same page to assign a php variable then you can share it.