HTML Coding


  1. Posts : 50
    Windows 8.1 x64
       #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>
      My Computer


  2. Posts : 1,049
    Windows 7 Pro 32
       #2

    marthijn99 said:
    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 Computer


  3. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #3

    Tookeri said:
    marthijn99 said:
    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 Computer


  4. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #4

    Tookeri said:
    marthijn99 said:
    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 Attached Thumbnails HTML Coding-naamloos.png  
      My Computer


  5. Posts : 1,049
    Windows 7 Pro 32
       #5

    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 Computer


  6. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #6

    Tookeri said:
    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 Computer


  7. Posts : 1,049
    Windows 7 Pro 32
       #7

    Sorry, don't know about that. Maybe something to do with the Blob object but that's just a guess....
      My Computer


  8. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #8

    Tookeri said:
    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 Computer


  9. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #9

    tread clossed since i cant find anny new info of waiting
      My Computer


  10. Posts : 50
    Windows 8.1 x64
    Thread Starter
       #10

    Thanks every one for the help
      My Computer


 

  Related Discussions
Our Sites
Site Links
About 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 04:53.
Find Us