I have an html form with text inputs and checkboxes. I want to be able to download a text file once I click submit form, with both the text inputs and checkbox inputs showing in the file.
I found a solution to download data from a textbox into a text file, but I do not know how to modify it so more text inputs are also downloaded and the checkbox inputs are as well (Can I save input from form to .txt in HTML, using JAVASCRIPT/jQuery, and then use it?)
<html>
<head>
<script language="Javascript" >
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(Notes));
pom.setAttribute('download', filename);
pom.style.display = 'none';
document.body.appendChild(pom);
pom.click();
document.body.removeChild(pom);
}
function addTextTXT()
{
document.addtext.name.value = document.addtext.name.value + ".txt"
}
</script>
</head>
<body>
<form name="addtext" onsubmit="download(this['name'].value, this[’Notes’].value)">
Notes:<input type="text" name=“Note/Users/karlahaiat/Desktop/Copia de checklist.htmls”><br>
Initials:<input type="text" name=“Initials”><br>
<input type="checkbox" name=“check_list[]” value=“Check General Health”> <b>Check General Health.</b><br>
<input type="checkbox" name=“check_list[]” value=“Check Fluid”> <b>Check Fluid.</b><br>
<input type="text" name="name" value="" placeholder="File Name">
<input type="submit" onClick="addTexttxt();" value="Save As TXT">
</form>
</body>
</html>
The form shows the input fields I want in my form, but the text file won't download. Any help understanding the syntax would be great!
Aucun commentaire:
Enregistrer un commentaire