samedi 27 décembre 2014

How to efficiently record user typing using javascript and store in database?


new to the site so not that familiar with the set-up.


I've made a simple javascript application for personal use, which is essentially a calculator, and the output is dynamic (do not need to submit or press enter to retrieve results). I want to be able to record the calculations I make so that I can recall them at a later date should I require the need to.


in simple terms, I have an input field on my website and would like to record the keystrokes and save them to a database or file so that I may read them later.


I'm just learning javascript so if you can explain it as fully as possible that would be much appreciated!


Thanks, -John


EDIT--


Added code in it's simplest form:



<html>
<head>
<title>Text Summation</title>

<script type="text/javascript">
function calc(A,B,SUM) {
var one = Number(A);
if (isNaN(one)) { alert('Invalid entry: '+A); one=0; }
var two = Number(document.getElementById(B).value);
if (isNaN(two)) { alert('Invalid entry: '+B); two=0; }
document.getElementById(SUM).value = one + two;
}
</script>

<body>
<form name="form" >
first number:
<input name="sum1" id="op1" value="" onChange="calc(this.value,'op2','result')" />
plus second number:
<input name="sum2" value="" id="op2" onChange="calc(this.value,'op1','result')" />
is:
<input name="sum" value="" id="result" readonly style="border:0px;">
</form>

</body>
</html>




Aucun commentaire:

Enregistrer un commentaire