This is a javascript code which saves a textarea onto a text file. This fiddle does the same.:
https://jsfiddle.net/pzvvhfv6/
I needed to add this feature in my code, so modified it so that onclick of the button, the text area is saved and a new file is created. But, for some strange reason, it shows uncaught reference error onclick. Below is the code Im working on.
https://jsfiddle.net/vu7thh34/
function call(){
var create = document.getElementById('create');
var textbox = document.getElementById('textbox');
var link = document.getElementById('downloadlink');
link.href = makeTextFile(textbox.value);
link.style.display = 'block';
}
HTML:
<textarea id="textbox">Type something here</textarea> <button id="create">Create file</button> <a download="info.txt" id="downloadlink" style="display: none">Download</a>
Is there any problem with the code?