Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: HTML Coding

02 Sep 2014   #1
marthijn99

Windows 8.1 x64
 
 
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>


My System SpecsSystem Spec
.
02 Sep 2014   #2
Tookeri

Windows 7 Pro 32
 
 

Quote   Quote: Originally Posted by marthijn99 View Post
save a file i made in the html web page
What editor are you using? I can't see anything wrong with the code except perhaps the lack of a <form> but I don't think that's necessary. So try another editor or simply Notepad. It's probably a problem with the editor you're using.
My System SpecsSystem Spec
02 Sep 2014   #3
marthijn99

Windows 8.1 x64
 
 

Quote   Quote: Originally Posted by Tookeri View Post
Quote   Quote: Originally Posted by marthijn99 View Post
save a file i made in the html web page
What editor are you using? I can't see anything wrong with the code except perhaps the lack of a <form> but I don't think that's necessary. So try another editor or simply Notepad. It's probably a problem with the editor you're using.

okay will try that
My System SpecsSystem Spec
.

02 Sep 2014   #4
marthijn99

Windows 8.1 x64
 
 

Quote   Quote: Originally Posted by Tookeri View Post
Quote   Quote: Originally Posted by marthijn99 View Post
save a file i made in the html web page
What editor are you using? I can't see anything wrong with the code except perhaps the lack of a <form> but I don't think that's necessary. So try another editor or simply Notepad. It's probably a problem with the editor you're using.
yes i tryed that what you d say but the problem is that the file it must create with the info i filled in does not save only the first line in the form PS: see the screen shot to the left is the web page with the filled in info an to the right is the outcome of the form saved in a file as it must do in the form

kindly regards marthijn99 aka marthijnwennemers


Attached Thumbnails
HTML Coding-naamloos.png  
My System SpecsSystem Spec
02 Sep 2014   #5
Tookeri

Windows 7 Pro 32
 
 

Ok. I misunderstood you before. That is probably because you have the same id value for all textareas, so only the first one will be handled properly.

<textarea id="inputTextToSave"

Change the id's to inputTextToSave1, inputTextToSave2 etc.
My System SpecsSystem Spec
02 Sep 2014   #6
marthijn99

Windows 8.1 x64
 
 

Quote   Quote: Originally Posted by Tookeri View Post
Ok. I misunderstood you before. That is probably because you have the same id value for all textareas, so only the first one will be handled properly.

<textarea id="inputTextToSave"

Change the id's to inputTextToSave1, inputTextToSave2 etc.

okay that should work but for the one or another reason i cant save it file as txt any more
My System SpecsSystem Spec
02 Sep 2014   #7
Tookeri

Windows 7 Pro 32
 
 

Sorry, don't know about that. Maybe something to do with the Blob object but that's just a guess....
My System SpecsSystem Spec
03 Sep 2014   #8
marthijn99

Windows 8.1 x64
 
 

Quote   Quote: Originally Posted by Tookeri View Post
Sorry, don't know about that. Maybe something to do with the Blob object but that's just a guess....
okay so ...... you dont know a fix ? and the blob object how do i fix that ?
My System SpecsSystem Spec
16 Sep 2014   #9
marthijn99

Windows 8.1 x64
 
 

tread clossed since i cant find anny new info of waiting
My System SpecsSystem Spec
16 Sep 2014   #10
marthijn99

Windows 8.1 x64
 
 

Thanks every one for the help
My System SpecsSystem Spec
Reply

 HTML Coding




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
[REQ] Coding Tutorial Website
As my adventures through Cisco begin, I've been wanting to expand my knowledge to make myself a more valuable employee. I've done some dabling in C++ when I was younger, but I've forgotten all that I learned. I'm looking for tutorials that start with the basics, and work towards the advanced/pro...
Chillout Room
Portable Coding Notepad...
I'm looking for a portable version of Notepad++ or something similar to it. I'm currently using Notepad++ but it doesn't have the compile feature for some reason, and it won't include things like "windows.h" or other things needed. I can't even save the HTML/PHP/CSS/PHP files either. ...
Chillout Room
Character coding problem on W7 Pro x64
First of all, I'm a Romanian and that's part of the reason I opened this thread. I used to run x86 on my notebook and after I've downloaded a movie, the sub was perfect with the correct characters (ă, ș, ț), aka Unicode. After I chenged to x64, the characters went crazy. I mean, for the SAME movie,...
General Discussion
Intros and coding
I'm new to the forums, hi! I have been coding for a while, and I end up writing apps for myself. So I figure what better place to tell people than the seven forums. This time I was learning the Windows 7 API, jump lists specifically. What was born was Linx, which you pin to your task bar,...
Chillout Room
Microsoft.NET and C# coding
HAve just taken up c# and downloaded MVisualStudio 9. This seems fine but tried to follow example for using command line entry using Notepad and a .NET builder called csc.exe Apparently this should have come with VS9 or .NET but .NET appears to be missing stuff as well. Can anybody give me an...
Software
Dangerous coding errors revealed
he US National Security Agency has helped put together a list of the world's most dangerous coding mistakes. The 25 entry list contains errors that can lead to security holes or vulnerable areas that can be targeted by cyber criminals. Experts say many of these errors are not well understood...
Chillout Room


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:25.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App