1

<!DOCTYPE html>
<html>
<head>
  <title>User information</title>
  
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
  <form>
    
  </form>


<h1>User information</h1>

  <label>Starting: <br/>    Date : </label><input id="StartingDate" type="date"/>  Time : <input id = "StartingTime" type="time"/>

  <br/>
  <br/>

  <label>Ending: <br/>    Date : </label><input id="EndingDate" type="date"/>  Time : <input id="EndingTime" type="time"/>

  <br/><br/><br/>

  <label>Application</label>
  <select id="selector">
  <option disabled value="">Please select one</option>
  <option>NGINX</option>
  <option>HSS-FE</option>
  <option>C</option>
  </select>
 <p>Selected: <span id="selected">NGINX</span></p>

 
  <br/><br/>

<label>Parameters:</label>
<div id='example-3'>
  <input type="checkbox" id="CPU" value="CPU" v-model="checkedNames">
  <label for="CPU">CPU</label>
  <input type="checkbox" id="MEMORY" value="MEMORY" v-model="checkedNames">
  <label for="MEMORY">MEMORY</label>
  <input type="checkbox" id="LATENCY" value="LATENCY" v-model="checkedNames">
  <label for="LATENCY">LATENCY</label>
  <br>

</div>

  <br/><br/>

<button>SUBMIT</button>
<script type="text/javascript" src="script.js"></script>
</body>
</html>

This is all I have for the front end. After the user fills in all the information(startingTime, endingTime, application, parameters) and clicks "SUBMIT", all the information will be saved and exported to a text file. I don't know how to write a javascript to address the problem. Thanks a lot for helping me out!!!

3
  • export it where? Local Machine, server, etc? Commented Jun 13, 2018 at 19:23
  • Check this out stackoverflow.com/questions/461791/… Commented Jun 13, 2018 at 19:25
  • export to a local file. Commented Jun 13, 2018 at 19:39

2 Answers 2

1

Answer is here -> https://www.roseindia.net/javascript/javascriptexamples/javascript-write-to-text-file.shtml

function createFile(){
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\Hello.txt", false);
file.WriteLine('Hello World');
file.WriteLine('Hope is a thing with feathers, that perches on the soul.'); 
file.Close();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, so I add all the objects like this document.querySelector("button").addEventListener("click",createFile()) var object = { startDate:document.getElementById('StartingDate').value, startTime:document.getElementById('StartingTime').value, endDate:document.getElementById('EndingDate').value, endTime:document.getElementById('EndingTime').value }; and i used "file.WriteLine(Object.values(object));" trying to print it. But I didn't get anything in my txt file.
1

You can use data URI as following:

<a href="data:application/octet-stream;utf8,test&nbsp;content">text file</a>

this will download text contents as a file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.