我正在尝试创建一个 HTML 系统,它通过 phonegap 创建一个 .txt 表单。
我的 HTML 元素就是这样
脚本
function Savenote() {
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
function gotFS(fileSystem) {
fileSystem.root.getFile("DCC.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwriteend = function(evt) {
console.log(" ' '");
writer.truncate(11);
writer.onwriteend = function(evt) {
console.log(" ' '");
writer.seek(0);
writer.write("Henry Aspden");
writer.onwriteend = function(evt){
console.log(" ' '");
}
};
};
writer.write("some sample text");
}
function fail(error) {
console.log(error.code);
}
}
</script>
我的身体/形式
<form>
<input type="text" style="width:100%" name="filename" placeholder="Enter File Name">
<textarea rows="10" style="width:100%" name="notes" placeholder="Enter Your Text Notes Here"></textarea>
</form>
<a href="#" onClick="Savenote()"><h1>SAVE</h1></a>
那我的问题是什么? 我需要从表单字段中获取函数中的值......如果可能的话,这就是
它说的地方
fileSystem.root.getFile("DCC.txt", {create: true, exclusive: false}, gotFileEntry, fail);
}
“ DCC.txt”部分必须替换为“文件名”字段(即“DCC.txt”仅用于演示目的)。此外,扩展名 .txt 是一个常量,所以如果有意义的话,它应该是 'filename'.txt 吗?
它说的地方
writer.write("Henry Aspden");
“ Henry Aspden”部分必须替换为“notes”字段(即“Henry Aspden”仅用于演示目的)
编辑编号 1 更改为
function gotFS(fileSystem) {
fileSystem.root.getFile("var filename = document.getElementById("filename");", {create: true, exclusive: false}, gotFileEntry, fail);
}
和
<input id="filename" type="text" style="width:100%" name="filename" placeholder="Enter File Name">
我认为这里会导致语法错误......我怎样才能将这个新变量放在这个现有函数中?
谢谢