Every time you call the function test, your variable is RE initialized to zero. You either need to use a global variable outside the function, or don't use a loop at all, and use set interval instead...
Did you post the HTML somewhere, because I didn't see it. Also, what browsers must it work in? I assume the p's have to be editable one at a time, yes, and onclick of some element?
If this is a beginner course, the code above might draw suspicion that you didn't do it yourself. Here's a very simplistic working example I just whipped up
When you say "a save button" do you mean just for that page load, or subsequent page loads as well? Because if it's the latter, it requires either local storage or a cookie, if only JavaScript is to...
There is no other option. Today's web pages have so much scripting that if a user disabled JavaScript in most cases the site will become unusable for them.
That's exactly what's happening. The last line is running before the vars are populated. They're printing null strings because that's what they're set to.
My 2¢, don't build anything today that will be antiquated tomorrow. HTML5 is mostly about search engines and more semantic markup, so even if there is no immediate benefit today, there will be...
function printDate() {
var month,today,year,mydate;
var now = new Date();
month = now.getMonth();
today = now.getDate();
year = now.getFullYear();
mydate = month + "/" + today + "/" + year;...
There's more to this than just not validating. The script simply won't work with duplicate IDs. They must never be duplicated under any circumstances. IDs MUST be unique on each page, period.
If you lived a bit closer I could get you a job. I got one for one of my former coworkers at draft, where I worked before CNBC. There is tons of work in this city and the surrounding areas for...