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>
Saurabh_13 0 Newbie Poster
stultuske 1,116 Posting Maven Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.