Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to save in local storage? (html 5 new features)

    i want to save an info in local storage and post it under the table.. how can i do that?

    <html>
    <head>
    <title>Offline App(Traffic Enforcement)</title>
    <link rel="stylesheet" type="text/css" title="Preferred" href="popAddVio.css" />

    <script type="text.javascript">


    function save() {
    try {
    var date = document.getElementById('textDate').value;
    var plate = document.getElementById('textPlate').value;
    var name = document.getElementById('textName').value;
    var address = document.getElementById('textAddress').value;

    localStorage.lDate = date;
    localStorage.lPlate = plate;
    localStorage.lName = name;
    localStorage.lAddress = address;

    } catch (e) {
    alert("Error save");
    }
    }
    function load() {

    var storedValue = localStorage.lDate;
    if (storedValue) {
    document.getElementById('date').value = storedValue;
    }
    }
    </script>
    </head>

    <body >

    <header>
    <h1>Add Violations</h1>
    </header>

    <div id="vioForm">
    <form>
    <table border="0" width="400" align="center">
    <tr>
    <td><label>Date:</label></td>
    <td><input id="vioDate" type="date" name="textDate" value="2011-01-13"/></td>
    </tr>
    <tr>
    <td><label>Plate #:</label></td>
    <td><input id="vioPlate" type="text" name="textPlate"</td>
    <tr>
    <td><label>Driver's Name:</label></td>
    <td><input id="vioName" type="text" name="textName" /></td>
    </tr>
    <tr>
    <td><label>Address:</label></td>
    <td><input id="vioAddress" type="text" name="textAddress"/></td>
    </tr>
    <tr>
    <td><label>Violation:</label></td>
    <td><select id="combo">
    <option value="move"> Moving Violation </option>
    <option value="park"> Parking Violation </option>
    </select></td>
    </tr>

    </table>
    </form>
    </div>

    <div>
    <form id="buttons">
    <input type="button" value="SAVE" onclick="save()" />
    <input type="button" value="CLOSE" onclick="window.close()" />
    </form>
    </div>




    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Code:
    var storage, fail, uid;
    try{
      uid = new Date();
      storage = window.localStorage;
      storage.setItem(uid,uid);
      fail = storage.getItem(uid) != uid;
      storage.removeItem(uid);
      fail && (storage = false);
      }catch(e){}
    
    if(storage){ alert("Storage YES"); } else { alert("Nope.. ain't happenin'"); }
    Upload to a server; this will let you know if localStorage is working.

    localStorage is set: storage.setItem() (based upon the variable 'storage', set above)
    localStorage is get: storage.getItem()
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

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