Results 1 to 6 of 6

Thread: Workaround to remember the form inputs.

  1. #1

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Workaround to remember the form inputs.

    Hi Guys,

    I don't know where should I post this question, so please moderator and administrator if you want to move this thread on a appropriate one, thank you so much.

    But let's go to my concern. Right now I'm currently developing a website application for our company. Most likely, its more on form inputs of records. So as a user experience, inputting a lot of data of would be a hassle if I accidentally press the back button, refresh button or even close the browser and suddenly all the work I done was gone.

    So how of most you guys handle this case?

    BTW, i'm using MVC 2, C# and MSSQL, together with JQuery.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: Workaround to remember the form inputs.

    There are a couple options I can think of off the top of my head:

    #1 Use local storage (http://www.html5rocks.com/en/features/storage)
    #2 Post the data via Ajax to the server

    Both of the above would simply prompt the user when they come back saying it looks like you had an unfinished entry, and whether they want to continue or start a new. You could save the data every 30 seconds or something.


    For the page refresh or page back button, you can use onbeforeunload (https://developer.mozilla.org/en-US/...onbeforeunload) to prompt them before they refresh or click back letting them know that data loss could occur.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Workaround to remember the form inputs.

    I would go a bit further with what kfcSmitty suggested. Local storage is a pretty simple animal, but very useful. However, it is particularly useful if you do a lot of the site with JavaScript/JQuery. For example, I recently wrote a web app/site that was intended to be used disconnected on tablets. There was no connection to a server, so posting to the server was right out. However, the app consisted of multiple forms. The user moved between forms via JQuery hiding and showing forms, which made it appear that you were navigating between pages even though all you were really doing was looking at a single page and showing/hiding things as needed. The fact that people thought they were moving between pages meant that people would often hit the back button on the browser out of habit (oddly, this habit only showed up on desktops, whereas there was no issue on the tablets, but that's irrelevant), which would unload the whole thing, since the whole thing was just the one page.

    The other issue I had to solve was that some of the tablets would overheat and shut down. So, I needed to store the state whenever it changed. So, all the user input was written to a JSON object, and that JSON object was written to Local Storage. Local Storage is effectively a Dictionary( of String, Object)....in .NET terms. What I wasn't sure about was whether or not the performance in the browser would be adequate to handle writing out a fairly sprawling JSON object with every click by the user (each click could be the entering of new data or alteration of existing). Clicks could come VERY fast, in this case, so speed of writing was a concern. As it turned out, writing to Local Storage was easily fast enough that the user never even noticed.

    So, what I was doing was writing the JSON object that contained an entire survey to Local Storage with a key like "Current". When the page loaded, one of the first steps was to see whether Local Storage had a key called "Current". If so, then that object was loaded and all the information from the object was loaded into the controls on the form. If there was no key called "Current", then I could assume that the user wasn't in the middle of doing anything and would take it from there. The performance of the system was all I could ask for.
    My usual boring signature: Nothing

  4. #4
    New Member
    Join Date
    Nov 2015
    Location
    Dai Vi, Tien Du 220000, Viet Nam
    Posts
    2

    Re: Workaround to remember the form inputs.

    Please make your need more specific, as usually the browser will automatically save your input data of textbox.

  5. #5
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Workaround to remember the form inputs.

    What is this "auto save" you speak of? In our web systems, if someone closes out or hits the back button its "too bad so sad #CorporateLife".

  6. #6

    Thread Starter
    Fanatic Member aNubies's Avatar
    Join Date
    Aug 2008
    Posts
    558

    Re: Workaround to remember the form inputs.

    It's been a weeks now since I posted this topic. But I consider what @kfcsmitty suggested and thanks for the insights @shaggy. I gotta dig some information about this local storage thingy.

    @Jayinthe813 - yes indeed, that's how CorporateLife works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width