Thursday, September 23, 2010

Week8 – Javascrpit Prac in Class

Hey guys,

I'm doing this week practice about JavaScript. I finished Challenge Exercise, but I got the bug on the basic one. Who can help me?

Firstly, click here.

When you open the page, it should pop up the current date by coding:
var today = new Date();
alert(('today is ') + today);

And then, you can find the button named 'how many days old I am' on the bottom of the page. Click the button, and the days will display by coding:
var today = new Date();
(This is current date and time.)
var my_date = "1985,10,25 04:00:00";
(This is my birthday and time.)

var time1 = new Date(my_date);
var time2 = new Date(today);

var days = (time2.getTime() - time1.getTime())/86400000;
input value="how many days old I am" onclick="alert((days)+' days')" type="button"

However, the days is float. Question one: how to display only the integrate number?

Another bug is click the small pic, the following pic can't change except the first one. I don't know why. I try to open this page on my local computer, it works. But when I upload the folder into FTP client, it does not work. Who can help me?

Cheers,
Tingting

1 comment:

  1. OMG, the other bug is auto-fixed.....The pic can change now. I don't know why.... may be the explorer problem..... :(

    ReplyDelete