I am working on a search box, in this search box I search all rows and show results in tag, after I select the result, the value will add to the search box. But it doesn't show in the HTML tag. in the following lines I share the codes.
$(document).ready(function(){
$.ajaxSetup({ cache: false });
$('#search').keyup(function(){
$('#result').html('');
$('#state').val('');
var searchField = $('#search').val();
var expression = new RegExp(searchField, "i");
$.getJSON('json/db.json', function(data) {
$.each(data, function(key, value){
if (value.InstrumentID.search(expression) != -1 || value.LVal18.search(expression) != -1 || value.LVal18AFC.search(expression) != -1 || value.LVal30.search(expression) != -1 || value.CompanyLVal18AFC.search(expression) != -1 || value.CompanyLVal30.search(expression) != -1)
{
$('#result').append('<li class="list-group-item link-class"> '+value.LVal30+' | <span class="text-muted">'+value.LVal18AFC+'</span></li>');
}
});
});
});
$('#result').on('click', 'li', function() {
var click_text = $(this).text().split('|');
$('#search').val($.trim(click_text[0]));
$("#result").html('');
});
$("#getValue").click(function(){
console.log(value.LVal30);
});
});
also, the JSON format is like :
[{ "InstrumentID": "IR0101", "LVal18": "AR", "LVal18AFC": "AR", "LVal30": "AR", "CompanyInstrumentID": "IRO101", "CompanyLVal18AFC": "AR", "CompanyLVal30": "AR" }, { "InstrumentID": "IRR1C0101", "LVal18": "Chadormalu-R", "LVal18AFC": "AB", "LVal30": "AB", "CompanyInstrumentID": "IRO0001", "CompanyLVal18AFC": "AB", "CompanyLVal30": "AB" } ]
and I have a simple input like the below:
<div class="input-group">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="getValue" >Chose</button>
</div>
<input type="text" name="search" id="search" placeholder="Search" class="form-control" data-value >
</div>
<ul class="list-group" id="result"></ul>
as you see in the picture the I get the result in the box, but nothing happens in the console!

edit - adding error:
Uncaught ReferenceError: value is not defined
at HTMLButtonElement.<anonymous> (script3.js:138)
at HTMLButtonElement.dispatch (jquery-3.5.1.js:5429)
at HTMLButtonElement.elemData.handle (jquery-3.5.1.js:5233)
line 138 of script3.js is :
console.log(value.LVal30);