0

I'm fairly ok with HTML and Javascript but any lanuage solution will do as a learning experience.

I want to have many small text boxs on a website that the user can write into and on hitting enter the text box's value becomes what was input. The text box must be saved so that it can be seen by other uses of the website and updated.

Most of all I'd like it to be simple as there are 36 boxes in total.

Thanks in advance

James MV
  • 8,569
  • 17
  • 65
  • 96
  • 1
    Can you clarify this question? If the user is writing into a textbox, the textbox's value will be what they input by default. – Logan Serman Oct 24 '11 at 20:04
  • Yes, sorry, I just want it saved, so many users can come and fill in the boxes but all see each others results – James MV Oct 24 '11 at 20:08
  • 2
    You are going to have to implement some sort of database to save each person's results. That is, you will have to store the new values of each textbox on a server. You cannot do this with just HTML and Javascript, you will need a server side scripting language (like PHP or ASP) to manage the mechanism that you choose to store the data. – Logan Serman Oct 24 '11 at 20:11
  • I can do that, what sort of field should I use that can be both the input and display? – James MV Oct 24 '11 at 20:16
  • PHP would do it. You can use python and django but for this simple program, django's learning curve would be unnecessary. – Umur Kontacı Oct 24 '11 at 20:56
  • If you think to accept only recent browsers, you can rely on `localStorage`. The values can be restored via Javascript on other pages on the same domain. – MaxArt Oct 24 '11 at 21:03

1 Answers1

0

Here is a way derived of the autoSave we do in our web app:

  1. the user enter a field. The onfocus event is triggered, and start a setInterval to check for changes

  2. if a change occurs, the database is updated with the new value of the field. You need to choose the time you wait before saving. 250ms seems natural in our app.

  3. each key stroke clearInterval the pending setInterval

  4. In parallel another setInterval checks if the database has changed, like a doc version.
    If so, the fields modified by others are updated.

The polling in the step 4. could be replaced by a WebSocket if you have the chance to target only modern browsers.

Mic
  • 24,812
  • 9
  • 57
  • 70
  • I answered a while ago a similar question: http://stackoverflow.com/questions/2130275 – Mic Oct 26 '11 at 15:08