Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-25-2012, 07:24 PM   PM User | #1
ceerup
New Coder

 
Join Date: Apr 2012
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
ceerup is an unknown quantity at this point
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>
ceerup is offline   Reply With Quote
Old 05-25-2012, 08:51 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,364
Thanks: 18
Thanked 348 Times in 347 Posts
sunfighter is on a distinguished road
</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;
sunfighter is offline   Reply With Quote
Old 05-25-2012, 09:04 PM   PM User | #3
ceerup
New Coder

 
Join Date: Apr 2012
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
ceerup is an unknown quantity at this point
so how does it go exactly, where do i put this?

im confused, since i didnt make this script
ceerup is offline   Reply With Quote
Old 05-25-2012, 10:07 PM   PM User | #4
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
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>
Lerura is offline   Reply With Quote
Old 05-25-2012, 10:20 PM   PM User | #5
ceerup
New Coder

 
Join Date: Apr 2012
Posts: 38
Thanks: 1
Thanked 0 Times in 0 Posts
ceerup is an unknown quantity at this point
thanks alot for the help guys
ceerup is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:01 AM.


Advertisement
Log in to turn off these ads.