2016-01-15 63 views
0

我正在设定目标并显示进度,我使用进度元素。我想用php/js/other将我的目标保存到我的服务器上名为user.txt的.txt文件中。我已经试过这Write server text files with AjaxPHP write file from input to txt显示我想要的,但代替形式标签,我只想要2个输入字段 有没有什么办法可以合并这两个文件,以将我的数据从我的2个字段保存到文本文件(用户.TXT) 这里是我的代码:如何在不清除文本框的情况下将输入字段数据保存到文本文件

function myFunction() { 
 
    var x = document.getElementById("myTextarea").value; 
 
    document.getElementById("myProgress").value = x; 
 
} 
 

 
function myFunction2() { 
 
    var x = document.getElementById("myTextarea2").value; 
 
    document.getElementById("myProgress").max = x; 
 
}
progress { 
 
    color: #0063a6; 
 
    font-size: .6em; 
 
    line-height: 1.5em; 
 
    text-indent: .5em; 
 
    width: 30em; 
 
    height: 3em; 
 
    border: 1px solid #0063a6; 
 
    background: #fff; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 

 
<h3>Goal Progress:</h3> 
 
<progress id="myProgress" value="0" max="100"> 
 
</progress> 
 

 
<hr> 
 
<input type="text" id="myTextarea"></input> 
 
<button onclick="myFunction()">Add</button> 
 
<hr> 
 
<input type="text" id="myTextarea2" /> 
 
<button onclick="myFunction2()">Set Goal</button> 
 
<hr>

+0

你试过了什么? – HJerem

+0

我尝试合并链接中的文件和我的javascript – parseguy

+0

我没有看到写入文本文件的任何内容。 – HJerem

回答

0

在这里,我终于解开了我的困惑paradyme:

<html> 
 
<body onload="timer=setTimeout('myFunction2(); myFunction();',3000)"> 
 
<style> 
 
progress { 
 
    color: #0063a6; 
 
    font-size: .6em; 
 
    line-height: 1.5em; 
 
    text-indent: .5em; 
 
    width: 30em; 
 
    height: 3em; 
 
    border: 1px solid #0063a6; 
 
    background: #fff; 
 
} 
 
</style> 
 
<h3>Goal Progress:</h3> 
 
<progress id="myProgress" value="0" max="100"> 
 
</progress> 
 

 
<hr> 
 
<form action="form.php" method="POST"> 
 
add money: 
 
<input type ="text" name="field1" id="myTextarea"></input> 
 
<hr> 
 
Goal: 
 
<input type ="text" name="field2" id="myTextarea2"/> 
 
<input type="submit" name="submit" value="Save Data"> 
 
</form> 
 
<hr> 
 
<button onclick="myFunction2(); myFunction();">show new progress</button> 
 
<script> 
 
function myFunction() { 
 
    var x = document.getElementById("myTextarea").value; 
 
    document.getElementById("myProgress").value = x; 
 
} 
 
function myFunction2() { 
 
    var x = document.getElementById("myTextarea2").value; 
 
    document.getElementById("myProgress").max = x; 
 
} 
 
</script> 
 
</body> 
 
</html>

相关问题