Tra Từ Điển

Thời gianTiếtThứ 2Thứ 3Thứ 4Thứ 5Thứ 6
8g40 - 9g101Tiếng Việt
Tiếng Anh
Tiếng Việt
Tiếng Việt
9g10 - 9g302Nghỉ giải lao
Tiếng Anh
Nghỉ giải lao
Nghỉ giải lao
9g30 - 10g3Toán
Toán
Toán

Friday, November 12, 2021

Tên, tuổi, lời chào - JavaScript - Ngày 6

Untitled Document

//Code

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
#abc{color: red; font-weight: bold;}
</style>
</head>

<body>
<script type="text/javascript">
function chao(ts1, ts2)
{
ngay=new Date();
namht=ngay.getFullYear();
alert(namht);
tuoi=namht-parseInt(ts2);
document.getElementById("kq").innerHTML="Chào bạn <span id='abc'>"+ts1+"</span>. Hiện nay bạn đang "+tuoi+" tuổi";
}
</script>
<form id="form1" name="form1" method="post">
  <p>
    <label for="ten">Tên: :</label>
    <input type="text" name="ten" id="ten">
  </p>
  <p>
    <label for="namsinh">Năm sinh:</label>
    <input type="text" name="namsinh" id="namsinh">
  </p>
  <p>
    <input type="button" name="thuchien" id="thuchien" value="Thực hiện" onClick="chao(ten.value, namsinh.value)">
  </p>
</form>
<p id="kq"></p>
</body>
</html>
 

0 comments:

Post a Comment