Đại Cương Về Thiết Kế Web Và Lập Trình Web- P11
Số trang: 5
Loại file: pdf
Dung lượng: 163.87 KB
Lượt xem: 18
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Đại Cương Về Thiết Kế Web Và Lập Trình Web- P11: Giáo trình bao gồm 5 chương, mỗi chương đều có phần kiến thức lý thuyết và câu hỏi nghiên cứu cụ thể...
Nội dung trích xuất từ tài liệu:
Đại Cương Về Thiết Kế Web Và Lập Trình Web- P11http://www.ebook.edu.vn 51 var answer=eval(question); var output= “What is ” + question + “?”; var correct= ‘’; var incorrect= ‘’; //ASK THE QUESTION var response=prompt(output,”0); //CHECK THE RESULT return (response == answer) ? correct : testQuestion(question); } // STOP HIDING FROM OTHER BROWSERS --> VÝ dô 2: Example http://www.ebook.edu.vn 52 return (response == answer) ? correct : incorrect; } } // STOP HIDING FROM OTHER BROWSERS --> 3.1.8 T¹o ®èi t−îng trong JavaScripta. §Þnh nghÜa thuéc tÝnh cña ®èi t−îng: function student(name,age, grade) { this.name = name; this.age = age; this.grade = grade; } §Ó t¹o mét Object ta sö dông ph¸t biÓu new. VÝ dô ®Ó t¹o ®èi t−îng student1, ta sö dông khai b¸o: student1 = new student(“Bob”,10,75); Ba thuéc tÝnh cña ®èi t−îng student1 lµ : student1.name, student1.age, student1.grade VÝ dô ®Ó t¹o ®èi t−îng student2: student2 = new student(“Jane”,9,82); §Ó thªm thuéc tÝnh cho student1, ta cã thÓ lµm nh− sau: student1.mother = “Susan”; HoÆc chóng ta cã thÓ ®Þnh nghÜa l¹i hµm student function student(name,age, grade,mother) { this.name = name; this.age = age; this.grade = grade; this.mother = mother; }b. §èi t−îng lµ thuéc tÝnh cña ®èi t−îng kh¸c VÝ dô: http://www.ebook.edu.vn 53 function grade (math, english, science) { this.math = math; this.english = english; this.science = science; } bobGrade = new grade(75,80,77); janeGrade = new grade(82,88,75); student1 = new student(“Bob”,10,bobGrade); student2 = new student(“Jane”,9,janeGrade); student1.grade.math: dïng ®Ó lÊy ®iÓm To¸n cña student1 student2.grade.science: dïng lÊy ®iÓm m«n Khoa häc cña student2c. Thªm ph−¬ng thøc cho ®èi t−îng: function displayProfile() { document.write(“Name: “ + this.name + “”); document.write(“Age: “ + this.age + “”); document.write(“Mother’s Name: “ + this.mother + “”); document.write(“Math Grade: “ + this.grade.math + “”); document.write(“English Grade: “ + this.grade.english + “”); document.write(“Science Grade: “ + this.grade.science + “”); } function student(name,age, mother,grade) { this.name = name; this.age = age; this.grade = grade; this.mother = mother; this.displayProfile = displayProfile; } student1.displayProfile(); VÝ dô: Example http://www.ebook.edu.vn 54 document.writeln(“Annual Salary: ” + this.salary); document.write(“”); } //DEFINE OBJECT function employee() { this.name=prompt(“Enter Employee’s Name”,”Name”); this.number=prompt(“Enter Employee Number for “ + this.name,”000-000); this.socsec=prompt(“Enter Social Security Number for “ + this.name,”000-00-0000); this.salary=prompt(“Enter Annual Salary for “ + this.name,”$00,000); this.displayInfo=displayInfo; } newEmployee=new employee(); // STOP HIDING FROM OTHER BROWSERS --> H×nh 3.1 Form nhËp tªn nh©n viªn H×nh 3.2 Form nhËp møc l−¬nghttp://www.ebook.edu.vn 55 H×nh 3.3 Form hiÓn thÞ kÕt qu¶ VÝ dô: Example
Nội dung trích xuất từ tài liệu:
Đại Cương Về Thiết Kế Web Và Lập Trình Web- P11http://www.ebook.edu.vn 51 var answer=eval(question); var output= “What is ” + question + “?”; var correct= ‘’; var incorrect= ‘’; //ASK THE QUESTION var response=prompt(output,”0); //CHECK THE RESULT return (response == answer) ? correct : testQuestion(question); } // STOP HIDING FROM OTHER BROWSERS --> VÝ dô 2: Example http://www.ebook.edu.vn 52 return (response == answer) ? correct : incorrect; } } // STOP HIDING FROM OTHER BROWSERS --> 3.1.8 T¹o ®èi t−îng trong JavaScripta. §Þnh nghÜa thuéc tÝnh cña ®èi t−îng: function student(name,age, grade) { this.name = name; this.age = age; this.grade = grade; } §Ó t¹o mét Object ta sö dông ph¸t biÓu new. VÝ dô ®Ó t¹o ®èi t−îng student1, ta sö dông khai b¸o: student1 = new student(“Bob”,10,75); Ba thuéc tÝnh cña ®èi t−îng student1 lµ : student1.name, student1.age, student1.grade VÝ dô ®Ó t¹o ®èi t−îng student2: student2 = new student(“Jane”,9,82); §Ó thªm thuéc tÝnh cho student1, ta cã thÓ lµm nh− sau: student1.mother = “Susan”; HoÆc chóng ta cã thÓ ®Þnh nghÜa l¹i hµm student function student(name,age, grade,mother) { this.name = name; this.age = age; this.grade = grade; this.mother = mother; }b. §èi t−îng lµ thuéc tÝnh cña ®èi t−îng kh¸c VÝ dô: http://www.ebook.edu.vn 53 function grade (math, english, science) { this.math = math; this.english = english; this.science = science; } bobGrade = new grade(75,80,77); janeGrade = new grade(82,88,75); student1 = new student(“Bob”,10,bobGrade); student2 = new student(“Jane”,9,janeGrade); student1.grade.math: dïng ®Ó lÊy ®iÓm To¸n cña student1 student2.grade.science: dïng lÊy ®iÓm m«n Khoa häc cña student2c. Thªm ph−¬ng thøc cho ®èi t−îng: function displayProfile() { document.write(“Name: “ + this.name + “”); document.write(“Age: “ + this.age + “”); document.write(“Mother’s Name: “ + this.mother + “”); document.write(“Math Grade: “ + this.grade.math + “”); document.write(“English Grade: “ + this.grade.english + “”); document.write(“Science Grade: “ + this.grade.science + “”); } function student(name,age, mother,grade) { this.name = name; this.age = age; this.grade = grade; this.mother = mother; this.displayProfile = displayProfile; } student1.displayProfile(); VÝ dô: Example http://www.ebook.edu.vn 54 document.writeln(“Annual Salary: ” + this.salary); document.write(“”); } //DEFINE OBJECT function employee() { this.name=prompt(“Enter Employee’s Name”,”Name”); this.number=prompt(“Enter Employee Number for “ + this.name,”000-000); this.socsec=prompt(“Enter Social Security Number for “ + this.name,”000-00-0000); this.salary=prompt(“Enter Annual Salary for “ + this.name,”$00,000); this.displayInfo=displayInfo; } newEmployee=new employee(); // STOP HIDING FROM OTHER BROWSERS --> H×nh 3.1 Form nhËp tªn nh©n viªn H×nh 3.2 Form nhËp møc l−¬nghttp://www.ebook.edu.vn 55 H×nh 3.3 Form hiÓn thÞ kÕt qu¶ VÝ dô: Example
Tìm kiếm theo từ khóa liên quan:
Giáo trình thiết kế thiết kế web giới thiệu HTML ngôn ngữ HTML tài liệu thiết kế webGợi ý tài liệu liên quan:
-
Báo cáo thực tập: Đề tài thiết kế Web
77 trang 566 2 0 -
Giáo trình phân tích một số loại nghiệp vụ mới trong kinh doanh ngân hàng quản lý ngân quỹ p5
7 trang 470 0 0 -
Đề thi thực hành môn Thiết kế Web - Trường Cao đẳng nghề Vĩnh Phúc
3 trang 267 2 0 -
Giáo trình hướng dẫn phân tích các thao tác cơ bản trong computer management p6
5 trang 194 0 0 -
Giáo trình phân tích giai đoạn tăng lãi suất và giá trị của tiền tệ theo thời gian tích lũy p10
5 trang 169 0 0 -
Luận văn tốt nghiệp Công nghệ thông tin: Xây dựng website bán hàng nông sản
67 trang 142 0 0 -
38 trang 135 0 0
-
Khóa luận tốt nghiệp Công nghệ thông tin: Xây dựng website bán hàng nông sản
85 trang 115 0 0 -
MỘT SỐ ĐIỂM CẦN CHÚ Ý KHI THIẾT KẾ WEB
5 trang 112 0 0 -
GIÁO TRÌNH LẬP TRÌNH WEB_PHẦN 2_BÀI 3
3 trang 103 0 0