0% found this document useful (0 votes)
45 views

Javasript Exercises: // Khai Bao 2 Bien de Luu Ten Va Tuoi

This document provides lessons on JavaScript exercises including: 1) Prompting a user to enter their name and age and displaying it in bold and underlined text. 2) Displaying welcome and farewell messages when a button is clicked. 3) Creating functions to calculate the sum, difference, product and quotient of two numbers. 4) Creating functions in an external .js file to validate numbers and find min/max of 3 numbers. 5) Creating an interface to request a number between 1-100 and calculate its square root. 6) Creating additional lessons on solving equations, summing ranges of numbers, checking prime numbers, and more.

Uploaded by

dat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Javasript Exercises: // Khai Bao 2 Bien de Luu Ten Va Tuoi

This document provides lessons on JavaScript exercises including: 1) Prompting a user to enter their name and age and displaying it in bold and underlined text. 2) Displaying welcome and farewell messages when a button is clicked. 3) Creating functions to calculate the sum, difference, product and quotient of two numbers. 4) Creating functions in an external .js file to validate numbers and find min/max of 3 numbers. 5) Creating an interface to request a number between 1-100 and calculate its square root. 6) Creating additional lessons on solving equations, summing ranges of numbers, checking prime numbers, and more.

Uploaded by

dat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

JAVASRIPT EXERCISES

Lesson 1: For users to enter the name and age. Print the screen of the person's name and
age to the screen using the document.write function, in which the name is bold, the age is
underlined.

Guideline:
<HTML>
<HEAD> </HEAD>
<BODY>
<script language = "JavaScript">
var Ten, Tuoi; // Khai bao 2 bien de luu ten va tuoi
Ten = prompt("Bạn hãy nhập vào tên ", "");
Tuoi = prompt("Bạn hãy nhập vào Tuổi : ", 20);
document.write("Chào bạn : <B> " + Ten + "</B>");
document.write("<BR>"); // Xuống dòng
document.write("Tuổi của bạn là : <U> " + Tuoi + "</U>");
</script>
</BODY>
</HTML>

Lesson 2: Create a website with a command button, when opening the website, a message
will appear: “Chào mừng bạn đến với Website”, when the user clicks the command
button, the message is displayed: “Chúc bạn vui vẻ!”.
<HTML>
<HEAD> </HEAD>
<BODY>
<script language = "JavaScript">
alert("Chào mừng bạn đến với Website");
</script>
<input type="button" name="Button" value="Lời chúc" onclick="alert('Chúc
bạn vui vẻ!');" />
</BODY>
</HTML>

-1-
Lesson 3: Constructing the functions of General, Brand, Calculus and Trading of 2
numbers with the following names: Tong (a, b), Hieu (a, b), Tich (a, b), Thuong (a, b).
Apply calculation functions to the following Form:

Guideline:
Step 1: Create the following calculation function:
<script language="javascript">
function Tong(a,b){
var c=parseInt(a.value)+parseInt(b.value);
return c;
}

function Hieu(a,b){
var c=parseInt(a.value)-parseInt(b.value);
return c;
}

function Tich(a,b){
var c=parseInt(a.value)*parseInt(b.value);
return c;
}

function Thuong(a,b){
var c=parseInt(a.value)/parseInt(b.value);
return c;
}
</script>

Step 2: Create a web page that looks like an image with 3 text boxes named t1, t2, t3.
Create an onclick event for command buttons, a total button:
onclick="t3.value=Tong(t1,t2)"
-2-
Lesson 4: Creating Ham.js file includes the following functions:
• The function to check the input data is the real number of the range [-100,100]:
Kiemtra (a, b, c)
• Function to find the largest number of 3 numbers: TimMax (a, b, c)
• Function to find the smallest number of 3 numbers: TimMin (a, b, c)
Create Bai4.HTML file with the following interface:

Lesson 5: Create the HTML Web page as follows:

Request:
- Only enter values for 1 <n <100
- Build calculation functions from external Java.js File

-3-
Lesson 6: Create the HTML Web page as follows:

Lesson 7: Create member registration form as follows:

Request:
• Cells marked with (*) are required
• Email address is invalid when there is a space and there is no @ character.
• Username up to 8 characters
• The password entered twice is the same
Create running text Register a member, when you move the mouse on the word,
stop, move the mouse to another position to keep running.

-4-
Lesson 8: Please show the current date and time of the computer system when the Web
page is loaded. The displayed information looks like this:

Hôm nay là thứ 2, ngày 6 tháng 2 năm 2012

Lesson 9: Create the HTML Web page as follows:

-5-
Lesson 10: Create the HTML Web page as follows:

Lesson 11: Create the HTML Web page as follows:

-6-
Lesson 12: Create an image conversion website, when hovering over a small image, it
will display that image in zoom mode in the middle position.

Guideline:
Set name attribute for big picture in the middle: <img name=”anhto” ....>
In small photos, we build mouseover events on the image
<img onmouseover=”document.anhto.src=’tenanhto.jpg’;”
Lesson 13: Javascript application in creating the following menu:

-7-
Additional Exercises:
Lesson 1: Giải phương trình bậc nhất ax + b=0;
Lesson 2: Giải phương trình bậc hai ax2 + bx + c = 0;
Lesson 3: Nhập vào số n, in ra màn hình tổng các số nguyên liên tiếp từ 1 đến n.
Lesson 4: Nhập vào số n, in ra màn hình dãy số lẻ từ 1 đến n.
Lesson 5: Nhập vào số x thuộc khoảng từ 10 đến 100, nếu nhập sai thì yêu cầu nhập lại
cho đến khi x đúng rồi tính căn bậc hai của x.
Lesson 6: Nhập vào tháng, năm bất kỳ, xây dựng hàm In_Ngay(Thang, Nam) trả về số
ngày của tháng.
Lesson 7: Nhập vào số n. Xây dựng hàm tính n giai thừa GiaiThua(n).
Lesson 8: Nhập vào số n, xây dựng hàm kiểm tra n số nguyên tố KtraNT(n). Hàm trả về
1 nếu là nguyên tố ngược lại trả về 1.
Lesson 9: Xây dựng các hàm sau: Nhap_Mang(), In_Mang(), TongDuong(), Tich_Am(),
Dem_Le(), Dem_Chan().
Lesson 10: Xây dựng trang Web sau:

Yêu cầu:
 Xây dựng hàm Kiemtra(); Nếu giá trị a, b là rỗng thì yêu cầu người dùng nhập và
đưa con trỏ về tại vị trí cần nhập.
 Xây dựng hàm GiaiPT();

-8-

You might also like