DHTML = HTML + CSS + JavaScript

 

Create a home.html that will:

  1. Display today's date
  2. If today is Tuesday, display an alert message "Tuesday is Senior Appreciation Day!"
  3. Ask the user for his/her intent to register with us or not
  4. If the user wants to register with us, display the registration form (form.html)
  5. Else display the dinner's home page (frame.html)

 

User interaction: working with objects & methods

1.  Display today's date (pg.8.16)

            document.write("text" + variable)

 

Create the following home.html:

<HTML>

<TITLE>Welcome</TITLE>

<HEAD>

<SCRIPT LANGUAGE="javascript">

var Today=new Date();

var Day=Today.getDate();

var Month=Today.getMonth() + 1;

var Year=Today.getFullYear();

document.writeln("<CENTER>Today "+Month+"/"+Day+"/"+Year+"</CENTER>");

</SCRIPT>

</HEAD>

</HTML>

 

2.  Display alert message

            alert("message")

 

      if  (Today.getDay() == 2)

            alert("Tuesday is Senior Appreciation Day!")

 

3.   Prompt user for his/her input:

      prompt("message","default_text")

 

var ans=prompt("Do you want to register with us?", "Type yes/no here:");

if (ans == "yes")

{

  close();

  window.open("form.html");

}

else

{

  close();

  window.open("frame.html");

}

 

4.  Use buttons for page control

<BODY>

<FORM>

<CENTER>

<INPUT TYPE=button VALUE=Menu OnClick="location='frame.html';">

<INPUT TYPE=button VALUE=Register OnClick="location='form.html';">

</CENTER>

</BODY>