Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Nurbek Ismailov
2,068 Pointsneed help with getting data from input and storing in local storage, current code is not working
Hi, I need help with getting data from input and storing in local storage, here is my js and codepen http://codepen.io/coden/pen/vKaAAv
function User(name, email) { this.name = name; this.email = email; this.tesla = tesla.checked; this.leaf = leaf.checked; this.bmw = bmw.checked; };
function getUserData() { event.preventDefault (); var user_name = event.target.user_name.value var user_email = event.target.user_email.value; var newUser = new User(user_name, user_email); console.log (newUser); localStorage.setItem('userProfile', JSON.stringify(newUser)); } var personInfo = document.getElementById('personinfo') personInfo.addEventListener ("submit", getUserData);
2 Answers
Unsubscribed User
501 PointsHello there!
You have made so much mistakes in the linked codepen. I did not fixed everything because that would take more time for me but i gave the answer to your question here: http://codepen.io/zoltanradics/pen/grkKpL This version is still ugly, but it save the data into the local storage as you wished. I am not sure which course you are watching but consider to go back to HTML and Javascript basics again.
I hope i could help for you!
Nurbek Ismailov
2,068 Pointsthanks Zoltan. Can you be more specific of what is wrong with HTML?