Thursday, 29 April 2021

29/4/2021 JAVASCRIPT



<html>
<head>
<meta charset="utf-8"></meta>
<title>Javascript</title>
</head>

<body>
<script type="text/javascript">
// Chu thich cho 1 dong
/* cho nhieu dong*/

document.write("<p align='center'>Hello <b>abc</b></p>");
document.write("Hello xyz");
document.write("<table border='1' width='500'>");
document.write("<tr><td>Ten</td><td>Tuoi</td></tr>");
document.write("<tr><td>Ti</td><td>17</td></tr>");
document.write("</table>");

//Bien:
a=5;
var d;
b=7;
c="hello";
document.write("Gia tri cua bien c la:");
document.write(c);
//Phep noi chuoi: +
document.write("<br/>Gia tri cua bien a la:<b>"+a+"</b>");
d=a+b;
document.write("<br/>Gia tri cua bien d:"+d);
//Cac phep toan: +,-,*,/,%,^

//Mot so hop thoai:

//Hop thoai thong bao: su dung ham alert()
//alert("Hello xyz");


//Hop thoai nhap lieu: cho phep nhap du lieu tu ban phim, su dung ham prompt():
/*kq=prompt("Nhap gi do:","");
document.write(kq+a);*/
//tam=parseInt("0123"); sau khi thuc hien tam chua so 123
//parseFloat()
/*d="hello 123";
document.write("gia tri moi cua bien d la:"+d);*/

//document.write("Ban vua nhap:"+prompt("Nhap gia tri moi:",""))

//Hoi thoai xac nhan: su dung ham confirm():
/*tl=confirm("Ban co muon nghi khong?");
document.write("<br/>Ban vua chon:"+tl);
*/

//Cac phep so sanh: >, <, >=, <=, ==, != (khac)
//Cac phep logic: && (and), || (or), ! (not)
//0 tuong duong false; khac 0 tuong duong true


//Cac cau lenh cau truc co ban: if...else, switch...case, for, while, do...while...

//Cau truc if...else: cau truc dieu kien, cau truc re nhanh
/*if(dieu_kien)
lenh_p;
else
lenh_q;


lenh_p, lenh_q: cau lenh don, cau lenh cau truc khac, khoi lenh: { cac lenh } */
/*if(a>b)
{
document.write("Hello abc!");
document.write("Gia tri cua a la:"+a);
}
else
{
document.write("Hello 123!");
document.write("Gia tri cua b la:"+b);
}*/

/*if(dieu_kien)
lenh_p;*/
if(a>b)
{
document.write("Hello abc!");
}




document.write("<br/>Ket thuc trang!");
</script>
</body>
</html>

Javascript

0 comments:

Post a Comment