Thursday, 6 December 2012

Week 11

This Week we were introduced to Java Script and some basic functions. The tutorial required the use of two:
One that will display a greeting depending on the time of the day and the second that would make some help text disappear when we put the mouse over it.
The second one was quite hard to achieve, and it took me more than  hour to make it work, but after the hard work comes the reward.


Here is the code that allowed me to do both functions:


function greeting()
{
var d = new Date()
var time = d.getHours()
if (time<12)
{
  document.write("<h1>Good morning</h1>");
}
else if (time>10 && time<17)
{
  document.write("<h1>Good afternoon</h1>");
}
else
{
  document.write("<h1>Good evening</h1>");
}
}



(...)



var defaulttext = "Enter your address here" ;
var areatext = "" ;
window.onload = init ;

function init()
{
if (!document.forms["payment"]) return; 
document.forms["payment"].elements["address"].value = defaulttext;
areatext = "" ;
}

function searchclear()
{
document.forms["payment"].
elements["address"].value = areatext ;
}

function searchpopulate()
{
areatext = document.forms["payment"].
elements["address"].value ;
}



My web site has some clear flaws due to the lack of imagination to write normal text, but, on the technical aspect, I have used everything that I learnt about HTML and not only, to personalise my pages. The outcome of the site does not look very professional, but it is functional with an easy navigation bar and a common style throughout the pages.












All pages were validated with 0 errors.

1202236.studentplus.abertay.ac.uk/Week100/Index.html

No comments:

Post a Comment