简体   繁体   中英

How to capture keyboard input in a HTML form

I want to capture/save data while writing in a HTML form. I am using HTML , php , MySQL and Javascript .

I have a registration form having three fields. Suppose an user inputs in those three fields but did not save it. I want to capture all what the user wrote in those three fields/two fields/one fields (whatever he/she wrote).

How could I do this ? I do not know how to start.

UPDATE

图应该是这样的

Use contenteditable property of table.

JS

 function saveToDatabase(editableObj,column,id) { $.ajax({ url: "pTedit/saveedit.php", type: "POST", data:'column='+column+'&editval='+editableObj.innerHTML+'&id='+id, success: function(data){ $(editableObj).css("background","#FDFDFD"); } }); } 
HTML

 <table> <tr> <td></td> <td></td> <td></td> </tr> <tr> <td contenteditable="true" onBlur="saveToDatabase(this,'columnName','<?php echo $getData["id"]; ?>')">data</td> <td></td> <td></td> </tr> </table> 

in saveedit.php

//DB connection string $result = mysql_query("UPDATE tableName SET " . $_POST["column"] . " = '".$_POST["editval"]."' WHERE id=".$_POST["id"]);

Try this it may help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM