...

View Full Version : HTML Storage Script Not working.



ceerup
05-25-2012, 08:24 PM
<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>

sunfighter
05-25-2012, 09:51 PM
</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;

ceerup
05-25-2012, 10:04 PM
so how does it go exactly, where do i put this?

im confused, since i didnt make this script

Lerura
05-25-2012, 11:07 PM
Lots of errors:

if(typeof(Storage)!=="undefined")should be
if(typeof(localStorage)!=="undefined")
- - - - -
localStorage.edit=getElementById("edit"); you cannot use getElementById() alone.
it must be
element.getElementById("edit"); where element. most likely should be document.
and you are probably trying to use the innerHTML of #edit
so
localStorage.edit=document.getElementById("edit").innerHTML;- - - - -
$edit.blur(function(is wrong,unless you have assigned an element to $edit, e.g:

$edit=document.getElementById("edit")I guess you are trying to use jQuery's equvalent of document.getElementById(), then it must be
$('#edit').blur() and you are also trying to set the function as a parameter of the blur function
Use:
$("#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
localStorage.setItem( 'toDoData' , this.innerHTML)); but you do not use this data afterwards.
- - - - -
I guess that you are looking for this:
<script>
if(typeof(localStorage)!=="undefined")
{ localStorage.edit=document.getElementById("edit").innerHTML;
$("#edit').blur()=function(){
document.getElementById("edit").innerHTML=("Test of : " + localStorage.edit);
}
}
</script>

ceerup
05-25-2012, 11:20 PM
thanks alot for the help guys



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum