Skip to main content

Posts

Tính tổng, hiệu, tích, thương - Hàm JavaScript

Untitled Document Số 1:: Số 2:: Kết quả:: //Code <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <script type="text/javascript"> function tong(a,b) { a=parseInt(a); b=parseInt(b); document.getElementById("kq").value=a+b; } function hieu(a,b) { a=parseInt(a); b=parseInt(b); document.getElementById("kq").value=a-b; } function tich(a,b) { a=parseInt(a); b=parseInt(b); document.getElementById("kq").value=a*b; } function thuong(a,b) { a=parseInt(a); b=parseInt(b); document.getElementById("kq").value=a/b; } </script> </head> <body> <form id="form1" name="form1" method="post">   <p>     <label for="so1">Số 1::</label>     <inp...

Bài tập 2 - Tạo bảng - Hàm Javascript

Untitled Document Số dòng: Số cột: //Code <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <script type="text/javascript"> function tbang(ts1,ts2) { tam="<table border='1' width='80%'>"; for(i=1;i<=ts1;i++) { tam+="<tr>"; //là phép gán rút gọn của: tam=tam+"<tr>"; for(j=1;j<=ts2;j++) tam+="<td>&nbsp;</td>"; tam+="</tr>"; } tam+="</table>"; document.getElementById("kq").innerHTML=tam; } </script> <form id="form1" name="form1" method="post">   <p>     <label for="dong">Số dòng:</label>     <input type="text" name="dong" id="dong"...

Bài tập 1 - tính tổng - Hàm Javascript

Untitled Document Số 1:: Số 2:: Kết quả:: _________________ <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <script type="text/javascript"> function tong() { a=parseInt(document.getElementById("so1").value); b=parseInt(document.form1.so2.value); tam=a+b; document.getElementById("kq").value=tam; } function tong2(a,b) { a=parseInt(a); b=parseInt(b); document.getElementById("kq").value=a+b; } </script> </head> <body> <form id="form1" name="form1" method="post">   <p>     <label for="so1">Số 1::</label>     <input type="text" name="so1" id="so1">   </p>   <p>     <label for="so2">Số 2::</label>     <input type=...