Jump to content

JSON.stringify doesn't work (for me :/)


M4rtin1
 Share

Recommended Posts

Hallo, I want to make a todo list website for practicing, do you know why the JSON.stringify argument doesn't work in the script? The alert says: "eingabe = {}" no matter what I put in the input box. Thanks!

document.getElementById("addto").addEventListener("click", addtolist);


function addtolist() {
     var eingabe = document.getElementById('meininput');
     var liste = document.getElementById("liste").textContent;

    alert("eingabe = " + typeof eingabe + "     liste = "+ typeof liste + "      eingabe = " + eingabe.value + "     liste = "+ liste);

    var eingabestring = JSON.stringify(eingabe);

    alert("eingabe = " + typeof eingabestring + "     liste = "+ typeof liste + "      eingabe = " + eingabestring + "     liste = "+ liste);

    eingabestring.write('<br/>');
    eingabestring.write(liste);



     document.getElementById("liste").textContent = eingabe.nodeValue;

}

 

Link to comment
Share on other sites

You're probably looking for the value of the element:

var eingabe = document.getElementById('meininput').value;

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...