0

I'm trying to build a little web app that saves things you type to a localStorage variable. Here's some of my code so far:

<center> 
        <textarea style="background-color:#34373c; color:white; border:0px solid #34373c;" id="docbox" name="docbox" rows="100" cols="100"></textarea>
    </center>
    <script>
      localStorage.setItem('docbox', docbox);
      localStorage.getItem('docbox');
    </script>  
</center>

I was thinking some sort of tag but when you open the HTML and look at the console and type localStorage.docbox it tells you that docbox is a text box. I want it to tell me it's in the text box.

Thanks!

Maxwell
  • 11

2 Answers2

0

I don't think you can store objects on a localeStorage, only strings, you'd have to stringify your object and de-stringify to extract.

How to store objects in HTML5 localStorage

dizad87
  • 448
  • 4
  • 15
0

If you want to save the content of the textarea, you need to use the value.

docbox.value

madprops
  • 3,909
  • 5
  • 34
  • 42