<!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>
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
};
function createFile(){
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\Hello.txt", false);
file.WriteLine(object.value);
file.Close();
}
第一个片段是HTML GUI的代码,我想将用户输入的startDate startTime endDate和endTime导出到本地文件(我在磁盘C名称Hello.txt下创建了一个)。我使用的命令是'file.WriteLine(object.value);',但我在Hello.txt中没有得到任何东西。 有人能帮我解决问题吗?或者我该如何打印出来? 感谢