0
THE CODE BELOW IS FOR SAVING FORM DATA FROM HTML FORM TO A TEXT FILE IN THE LOCAL COMPUTER.  BUT, THE TEXT I AM GETTING IN THE TEXT FILE IS ALWAYS IN A SINGLE LINE AND I CAN'T ORGANIZE IT.  THE CODE BEING USED IS AS BELOW.
<!DOCTYPE html>
<html>
<head>
<style>
  form * {
    display: block;
    margin: 10px;
  }
</style>
<script language="Javascript" >
  function download(filename, text, text1) {
    var pom = document.createElement('a');
    pom.setAttribute('href', ' data:text/plain;charset=utf-8 \n,' + 
                     encodeURIComponent(text1) + '\n' + encodeURIComponent(text));

    pom.setAttribute('download', filename);

    pom.style.display = 'none';
    document.body.appendChild(pom);

    pom.click();

    document.body.removeChild(pom);
  }
</script>
</head>
<body>
<form onsubmit="download(this['name'].value, this['text']. value, this['problem'].value)">
  <b>Your Name Please</b>
<input type="text" name="name" value="test.txt">
<center><b>Part I</b></center>
<LEFT><B>QUESTION 1)</B><LEFT>
 1. Which of the following devices can be used to directly image printed text?<br>
  <input type="radio" name="radio" value="1.OCR" onclick="getElementById('problem').value=this.value;">(a) OCR
  <input type="radio" name="radio" value="1.OMR" onclick="getElementById('problem').value=this.value;">(b) OMR
  <input type="radio" name="radio" value="1.MICR" onclick="getElementById('problem').value=this.value;">(c) MICR
  <input type="radio" name="radio" value="1.ALL OF THE ABOVE" onclick="getElementById('problem').value=this.value;">(d) ALL OF THE ABOVE<BR/>
  <input type="hidden" name="problem" id="problem";><br/>
 <center><b>Part II</b></center>
 <LEFT><B>QUESTION 1)</B><LEFT>
         1. What do you understand by the term ISP?  What services does an ISP provide?
  <textarea rows=3 cols=50 name="text">PLEASE WRITE ANSWER HERE. </textarea>
  <input type="submit" value="SAVE">
</form>
          </body>
            </html>
2
Contributors
1
Reply
9
Views
1 Year
Discussion Span
Last Post by stultuske
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.