0

I need to check the database for saved info and if the database has info I want to paste that info in text boxes. The user should be able to edit the data when it is pasted to the text boxes.

The database can contain only one record and when the data is submitted the database will be erased.

5
  • mind sharing what is your data structure ? what is the expected number of records per query ? what have you tried? Commented Apr 13, 2015 at 6:23
  • in the database i have 7 fields. When the form is submitted all the 7 fields are entered in the database. Now when I reopen the page I want the data that was submitted previously to be displayed in the specific textboxes. The database is working fine.....but I'm not able to display the data when I reopen the page Commented Apr 13, 2015 at 6:26
  • this might help tutorialspoint.com/html5/html5_web_sql.htm these are useful queries to perform CRUD operations.. basically you will need to check if websql is supported then trigger a database connection when the app loads, then if table exists , fetch recrods, then on form submit update your table. or drop/insert - I have not used websql before but the logic should be the same.. Commented Apr 13, 2015 at 6:31
  • did you consider SQLite as an alternative ? Commented Apr 13, 2015 at 6:36
  • the project has lot of websql so changing it is a tedious task. Anyways found a solution. Thanks Commented Apr 13, 2015 at 6:43

1 Answer 1

1

Here is the solution I found:

function MyCtor(element, data) {
this.data = data;
this.element = element;
element.value = data;
element.addEventListener("change", this, false);
}
var x = "abc";
var y = "xyz";
var obj = new MyCtor(document.getElementById("foo"), x);
var obj = new MyCtor(document.getElementById("foo1"), y);
setInterval(function () {
obj.change(obj.element.value);
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.