<head>
<title> Javascript business card </title>
<script type ="text/javascript">
function PrintCard (){
line1 = "<b>Name: </b>" + this.name + "<br />\n";
line2 = "<b>Address: </b>" + this.Address + "<br />\n";
line3 = "<b>Work Phone: </b>" + this.workphone + "<br />\n";
line4 = "<b>Home Phone: </b>" + this.homephone + "<hr />\n";
document.write(line1, line2, line3, line4);
}
function Card (name, address, work, home){
this.name = name;
this.address = address;
this.work_phone = work;
this.home_phone = home;
this.PrintCard = PrintCard;
}
</script>
</head>
<body>
<h1>Javascript Business Card Test </h1>
Script begins here.
<hr />
<script type ="text/javascript">
sue = new Card("Sue suthers", "123 Elm street", "555-1234", "555-9876");
phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222", "555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle", "555-1299", "555-1344");
sue.PrintCard();
phred.PrintCard();
henry.PrintCard();
</script>
End of script.
</body>
</html>
-----------------------------------------------------------------------------------
output
Javascript Business Card Test
Script begins here.Name: Sue suthers
Address: undefined
Work Phone: undefined
Home Phone: undefined
Name: Phred Madsen
Address: undefined
Work Phone: undefined
Home Phone: undefined
Name: Henry Tillman
Address: undefined
Work Phone: undefined
Home Phone: undefined
End of script.
No comments:
Post a Comment