I have a JSON database with information that I would like to autofill in my JavaScript/HTML if a particular element in the array is found. I have an handler event, onchange to listen if that particular element is found, it prints all of the info of that particular array. I have it printing into the console, but how would I go about printing this onto my relevant HTML sections?
Are there any documents I should be looking at to help me with this?
The javascript
const getAssetInfo = id => {
$.get( "http://localhost:3000/assets/" + id, function( data ) {
console.log(data);
});
}
$('document').ready(() => {
<td><input id='asset_tag_no${count}' type='text' onchange = "getAssetInfo(this.value);" bottom required /></td>
<td><input id='manufacturer_serial_no${count}' type='text' bottom required/></td>
<td><textarea id='description${count}' type='text' bottom required description></textarea></td>
}
The database
{
"assets" : [
{
"id": "0946",
"description" : "SONY - Camera",
"manufacturer" : "SONY",
}
}