Click to See Complete Forum and Search --> : First Javascript Assignment HELP


Minx
10-28-2003, 07:53 AM
Please can someone help me, I have started a Master in Business Information Technology and I just received an assignment on Javascript. I have to design a train timetable where there is a basic form with boxes and some script written to generate times within these boxes. Where do I start??? I use the variables of station name, intervals between stations and the times the trains leave the first station. There is no user interaction at present, it just has to be a generated table/form thingy. Please can anyone save a damsel in distress???????

requestcode
10-28-2003, 10:53 AM
Check these sites out for some excellent tutorials:
http://www.javascriptkit.com/javaindex.shtml
http://www.htmlgoodies.com/primers/jsp/
http://hotwired.lycos.com/webmonkey/programming/javascript/
http://www.w3schools.com/

krautinator
10-28-2003, 11:51 AM
does it have to change constantly?

you could do a # of things like putting the times in an array
of variables:

var hourtimes = new array (5,10,15)
var minutetimes = new array(10,30,15)


\\then just check the time:

now = new Date

if(now.getHour() == hourtimes [0])
{

document.write("The 5 AM train has arrived")

}

or if it was something like 5:30

if(now.getHour() == hourtimes [0] && now.getMinutes() == minutetimes [1])

{
document.write("The 5:30 AM train has arrived")
}

course it's more complex than that w/ a table and all
but that's the basic idea, also since I'm a newbie, this is in military time...

hope that maybe this helps, if not it's just cuz I suc at Javascript (for the moment)

Minx
10-29-2003, 06:19 AM
http://www.kingston.ac.uk/~ku07009/Teaching/Progwww/jsExamples/timeInfo.html

This is what the table has to look like, but we are not allowed to use HTML to make the table.

Any help??? :D

krautinator
10-30-2003, 11:22 AM
about the table part:
you could use document.write()

like so:

document.write("<center><table width=50%><tr><td>blah</td><td>blah</td></tr></table></center>")


then I think you could add your times into the cells like so:

<td>+starttimes[0]+</td>