New
#1
HTML Coding
HI when i try to save a file i made in the html web page it only saves the first <textarea> thing and not the the remaining here is the code i use :
<html>
<body>
<table>
<tr><td>Text to Save:</td></tr>
<tr>
<td colspan="3">
<p>Geld Over Gehouden ?</p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Over Gehouden Bedrag Gekregen Van begeleiding:</p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Bedrag Gepind Van Rekening (Voor Je Zelf Dus Geen Recreatie Geld !): </p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Wat Heb Ik Over Gehouden/Is Er Afgegaan ?</p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Uitgegeven bedrag:</p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Totaal Bedrag:</p>
<textarea id="inputTextToSave" style="width:300px;height:22px"></textarea><br>
<p>Wat Heb Ik Allemaal Gekocht (Onderscheiden Met Een *. En Aangeven Wat Het Heeft Gekost!):</p>
<textarea id="inputTextToSave" style="width:300px;height:150px"></textarea><br>
</td>
</tr>
<tr>
<td>Filename to Save As:</td>
<td><input id="inputFileNameToSaveAs"></input></td>
<td><button onClick="saveTextAsFile()">Save Text to File</button></td>
</tr>
</table>
<script type='text/javascript'>
function saveTextAsFile()
{
var textToWrite = document.getElementById("inputTextToSave").value;
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
else
{
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
function destroyClickedElement(event)
{
document.body.removeChild(event.target);
}
function loadFileAsText()
{
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var textFromFileLoaded = fileLoadedEvent.target.result;
document.getElementById("inputTextToSave").value = textFromFileLoaded;
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
</script>
</body>
</html>