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
ian izaguirre
3,220 PointsI have an alert and prompt string written on my Wordpress Javascript file but where is the users information stored after they answer the popup question?
1.) I have an alert and prompt string written on my Wordpress Javascript file but where is the users information stored after they answer the popup question?
alert("Hello " + prompt("What is your name"));
The Javascript shows up running on here : http://izaguirre.me/contact/
My other question is , :
2.) Why does this javascript function only run on this page http://izaguirre.me/contact/ ? Is there a way to add something to dictate which pages the prompt is supposed to run on ?
3 Answers
Brian Clovis
5,899 Pointsthe difference is now the name is stored in a variable for use later on in the page if needed. EG. using it to fill out the name field in your form. if you want to store it for a longer duration , look into local or session storeage. For something you actualy 'see', your looking at doing something with a server side script to send to a database,
Brian Clovis
5,899 Pointsif you want o store the name for use later, try this:
var name = prompt("What is your name") alert("Hello " + name );
ian izaguirre
3,220 PointsHi thank you for helping me, when I put your code in to replace the original one, Where do I go to see the stored information ?
Brian Clovis
5,899 Pointsits stored in javascript memory so no real way to 'see' it. Depends really on what your trying to do
ian izaguirre
3,220 PointsSo if there is not real way to see it whats the difference with your code ? ( I got the original code from the javascript teamtree house video) , and whats the point of having someone type there name or information if its going to be erased in 5 seconds ? is it just for a temporary welcome message ?
ian izaguirre
3,220 Pointsian izaguirre
3,220 PointsThank you I understand this a lot better now :-) .... Whats the difference with changing the code by adding a var ?