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 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts

    HTML Storage Script Not working.

    <h2>Demo of Local Storage: My to do list </h2>
    <ul>
    <li id="edit" contenteditable="true"> </li >
    </u>

    // This part should store what's written.
    <script>
    if(typeof(Storage)!=="undefined")
    { localStorage.edit=getElementById("edit");
    $edit.blur(function(
    localStorage.setItem( 'toDoData' , this.innerHTML));
    if
    document.getElementById("edit").innerHTML=("Test of : " + localStorage.Edit);
    ) }
    </script>

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,598
    Thanks
    24
    Thanked 646 Times in 645 Posts
    </u> S/B </ul>

    $edit.blur Probable S/B $(edit).blur

    If your 'if' is correct you need () after it and if the
    document.getElementById("edit").innerHTML=("Test of : " + localStorage.Edit)

    and if that is what you want in there it's not coded right

    But if is a separate line it S/B

    document.getElementById("edit").innerHTML="Test of : " + Something;

  • #3
    New Coder
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    so how does it go exactly, where do i put this?

    im confused, since i didnt make this script

  • #4
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    947
    Thanks
    0
    Thanked 130 Times in 129 Posts
    Lots of errors:
    Code:
    if(typeof(Storage)!=="undefined")
    should be
    Code:
    if(typeof(localStorage)!=="undefined")
    - - - - -
    Code:
    localStorage.edit=getElementById("edit");
    you cannot use getElementById() alone.
    it must be
    Code:
    element.getElementById("edit");
    where element. most likely should be document.
    and you are probably trying to use the innerHTML of #edit
    so
    Code:
    localStorage.edit=document.getElementById("edit").innerHTML;
    - - - - -
    Code:
    $edit.blur(function(
    is wrong,unless you have assigned an element to $edit, e.g:
    Code:
    $edit=document.getElementById("edit")
    I guess you are trying to use jQuery's equvalent of document.getElementById(), then it must be
    Code:
    $('#edit').blur()
    and you are also trying to set the function as a parameter of the blur function
    Use:
    Code:
    $("#edit').blur()=function(){
    - - - - -
    you save the data as localStorage.edit but tries to read it as localStorage.Edit
    Javascript is case-sensitive, which means that they are not equal.
    - - - - -
    and you are storing the item toDoData by
    Code:
    localStorage.setItem( 'toDoData' , this.innerHTML));
    but you do not use this data afterwards.
    - - - - -
    I guess that you are looking for this:
    Code:
    <script>
    if(typeof(localStorage)!=="undefined")
    { localStorage.edit=document.getElementById("edit").innerHTML;
    $("#edit').blur()=function(){
    document.getElementById("edit").innerHTML=("Test of : " + localStorage.edit);
    }
    }
    </script>

  • #5
    New Coder
    Join Date
    Apr 2012
    Posts
    38
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks alot for the help guys


  •  

    Posting Permissions

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