1. Trang chủ
  2. » Công Nghệ Thông Tin

Hướng dẫn bài tập javarcipt

26 489 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 26
Dung lượng 636,39 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Click the back to see the Example Now put this anywhere in your page and change YOUR LINK DESCRIPTION YOUR LINK DESCRIPTION... onClick="a_minus_bthis.form"> = Tạo chương trình để kh

Trang 2

<html>

<head>

<title>Click the back to see the Example</title>

<meta name="GENERATOR" content="Copyright Next Step Software 1998 (c)">

Now put this anywhere in your page and change YOUR LINK DESCRIPTION

<a href="" onClick="rusure(); return false;">YOUR LINK DESCRIPTION</a>

Trang 4

onClick="a_minus_b(this.form)"> <input type="button" value=" x "

onClick="a_times_b(this.form)"> <input type="button" value=" / "

onClick="a_div_b(this.form)"> <input type="button" value=" ^ "

onClick="a_pow_b(this.form)"> <input type="number" size="4" value="3" name="b"> =

Tạo chương trình để khi bấm vào nút Play thì hình trong khung sẽ chuyển qua

hình khác một cách ngẫu nhiên Chương trình sẽ dừng khi bấm vào nút stop

Hướng dẫn : Tạo một site tên BT6 – tạo trong site này một thư mục hình ảnh

Images chứa bộ sưu tập hình

Trang 5

who=prompt("Enter recipient's email ađress: ","antispammer@earthling.net");

what=prompt("Enter the subject: ","none");

if (confirm("Are you sure you want to mail "+whơ" with the subject of "+what+"?")==true){ parent.location.href='mailto:'+whớ?subject='+what+'';

Trang 6

<td width="312" rowspan="5" align="center" valign="middle">

<img src="img/1.jpg" width="150" height="150" id="abc">

</td>

<td><select name="hinhxe" id="hinhxe" onChange="duyet(value)">

<option value="img/1.jpg" selected>hình 1</option>

<option value="img/2.jpg">Hình 2</option>

<option value="img/3.jpg">Hình 3</option>

<option value="img/4.jpg">Hình 4</option>

<option value="img/5.jpg">Hình 5</option>

<option value="img/6.jpg">Hình 6</option>

<option value="img/7.jpg">Hình 7</option>

Trang 7

<option value="img/8.jpg">Hình 8</option>

<FORM name="testform" onSubmit="return validate()">

Name:<input type="text" size=30 name="Name">

Age:<input type="text" size=3 name="age">

<input type="submit" value="Submit">

</FORM>

Trang 8

var m1 = "Welcome to Total JavaScript 99! ";

var m2 = " You can find all the scripts you need here! ";

Trang 9

"And this will be the third",

"And the fourth is the last !"

Trang 10

osd +="This is yet another JavaScript Scroll example ";

osd +="from the good folks at The JavaScript Source ";

osd +="This one has the date and time at the front.";

osd +="Did you notice? It's coming around again, look! ";

Trang 11

var hours= now.getHours();

var minutes= now.getMinutes();

var seconds= now.getSeconds();

var months= now.getMonth();

var dates= now.getDate();

var years= now.getYear();

var timeValue2 = " " + hours

timeValue2 += ((minutes < 10) ? ":0":":") + minutes + " " + ap return timeValue2;

Trang 12

var theDay = daysNames[oneDate.getDay() +1]

var theDate =oneDate.getDate()

var theMonth = monthNames[oneDate.getMonth() +1]

Tạo form sau để cập nhật thơng tin

Khi bấm vào nút Update và nếu nút radio ‘Vàng’ được chọn thì cập dữ liệu ở ‘Bảng tin thị trường’ trong mục ‘Vàng’ còn ngược lại thì cập nhật ở mục ‘USD’ tương ứng với trường ‘Mua vào’ của cột

‘Mua vào’ và trường ‘Bán ra’ của cột ‘Bán ra’ (Dùng inner để cập nhật)

Trang 15

<p><select NAME="site" SIZE="1" onChange="formHandler()">

<option VALUE>Go to </option>

<option VALUE="http://www.metacrawler.com">Metacrawler </option>

<option VALUE="http://www.altavista.digital.com">Altavista </option>

<option VALUE="http://www.webcrawler.com">Webcrawler </option>

<option VALUE="http://www.lycos.com">Lycos </option>

<option VALUE="http://www.javascriptsource.com">The JavaScript Source </option> </select></p>

<body link="ffffff" alink="ffffff" vlink="ffffff">

<font SIZE="+2" FACE="Coronet">

Trang 16

<b>Pass the mouse over the images </b><br>

<b>Check out the script! See how easy this function is.</b><br>

function GetCookie (name) {

var arg = name + "=";

var alen = arg.length;

var clen = document.cookie.length;

function SetCookie (name, value) {

var argv = SetCookie.arguments;

var argc = SetCookie.arguments.length;

var expires = (argc > 2) ? argv[2] : null;

Trang 17

var path = (argc > 3) ? argv[3] : null;

var domain = (argc > 4) ? argv[4] : null;

var secure = (argc > 5) ? argv[5] : false;

document.cookie = name + "=" + escape (value) +

((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +

((path == null) ? "" : ("; path=" + path)) +

((domain == null) ? "" : ("; domain=" + domain)) +

((secure == true) ? "; secure" : "");

}

function DeleteCookie (name) {

var exp = new Date();

exp.setTime (exp.getTime() - 1);

var cval = GetCookie (name);

document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); }

Trang 18

document.write("You've been here <b>" + amt() + "</b> times.")

Thiết kế Form như sau:

Viết chương trình xử lý theo yêu cầu bấm nút Nhap thì dữ liệu hiển thị vào bảng “Danh Sach Sinh Vien” ở bên dưới và nút Nhap lại mờ

Trang 19

22 Bài tập 22

Thiết kế trang web sau với yêu cầu sau:

− Khi load form nút thêm mờ, khi bắt đầu nhập họ tên nút thêm sáng

− Nếu không nhập họ tên thông báo lỗi

− Số chứng minh dữ liệu bắt buộc là số, chiều dài là 9 số

− Chọn hình, hình load trong ô load hình

− Khi nhập xong dữ liệu và click nút add dữ liệu nhập vào bảng bên dưới

Trang 20

image.innerText=option;

dulieu.id="dulieu"+dem;

stt.id="stt"+dem;

hoten.id="hoten"+dem;

Trang 21

{tbao=tbao+" _ bạn chưa nhập số cmnd";

} else

{tbao=tbao+" _ cmnd phải là số";

Trang 22

document.dky.cmnd.focus();

} else

if(document.dky.hokhau.value=="")

{tbao=tbao+" _ Hộ khẩu chưa điền"

} if(tbao!="")

{alert(tbao);}

else {nhap();

<tr>

<td><span class="style1">Qu&#7843;ng c&aacute;o</span></td> </tr>

Trang 23

<td width="600" height="600" align="left" valign="top">

<form action="" method="post" name="dky" id="dky">

<table width="594" border="1">

<tr align="center" valign="middle">

<td colspan="3" class="cls">&#272;&#259;ng k&yacute;

gi&#7845;y ph&eacute;p l&aacute;i xe &ocirc; t&ocirc;</td>

<td width="312" rowspan="5" align="center" valign="middle"><img

src=" /img/1.jpg" width="150" height="150" id="abc"></td>

Trang 24

<option value=" /img/1.jpg" selected>hình 1</option>

<option value=" /img/2.jpg">Hình 2</option>

<option value=" /img/3.jpg">Hình 3</option>

<option value=" /img/4.jpg">Hình 4</option>

<option value=" /img/5.jpg">Hình 5</option>

<option value=" /img/6.jpg">Hình 6</option>

<option value=" /img/7.jpg">Hình 7</option>

<option value=" /img/8.jpg">Hình 8</option>

Trang 25

<td width="32">STT</td>

<td width="160">Họ Tên</td> <td width="122">Số CMND </td> <td width="119">Hộ khẩu</td> <td width="131">Hình</td>

</tr>

<tr id="dulieu">

<td id="stt">&nbsp;</td>

<td id="hoten">&nbsp;</td> <td id="socm">&nbsp;</td>

<td id="diachi">&nbsp;</td> <td id="image">&nbsp;</td> </tr>

<tr>

<td width="59">&nbsp;</td> <td width="59">&nbsp;</td> <td width="460">&nbsp;</td> </tr>

Trang 26

24

Ngày đăng: 21/07/2014, 19:53

TỪ KHÓA LIÊN QUAN

w