I need to create a Change log table that will track any changes made in the drop-down menu. For instance, I am working on a worksheet with a select menu called Results which includes options like Positive, Negative, Unknown. I want the system to log any changes from Positive to Negative or any other option with a timestamp.
Currently, I have a version of the code that works with input fields but it doesn't capture changes in the select field (drop-down menu).
Here is the code I am using for input fields, which is functioning properly:
$(document).on('focusin', 'input', function()
{
console.log("Saving value " + $(this).val());
$(this).data('val', $(this).val());
}
).on('change','input', function(){
var prev = $(this).data('val');
var current = $(this).val();
var date1 = Date();
if (prev !== current) {
$(this).css("color", $currentDayColor);
$specimenInfo = "";
if((prev != current) && (prev!= null) && (prev != " ")){
document.getElementById("demo").innerHTML = document.getElementById("demo").innerHTML + $specimenInfo + 'The Prev Value is :' + prev +' Which was changed on :'+ date1+'<br>';
document.getElementById("demo2").innerHTML = document.getElementById("demo2").innerHTML + $specimenInfo + ' The Current Value is :' + current +' Which was changed on :'+ date1 + '<br>';
console.log("Prev value " + prev);
console.log("New value " + current);
}
};
});