I need a function to modify the value attribute in the input element when the user modifies it. I have a function that downloads the html into a text file. I want the file to accurately record the current value of the element, not what it was on load.
JS download function:
function saveActors() {
let fileName = `page.txt`;
let a = document.createElement("a");
let target = document.getElementById('target');
a.download = fileName;
let content = new Blob([target.innerHTML], {type: 'text/plain;charset=utf-8'});
a.href = window.URL.createObjectURL(content);
a.click();
}
HTML:
<div id="target">
<input type="text" value="" onchange="updateValue(this)">
</div>
<script>
function updateValue(a) {
// update the input value
}
</script>