<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
var arr = new Array(2);
arr[0] = new Array("ACCP-S1","ACCP-S2","ACCP-Y2");
arr[1] = new Array("BENET-S1","BENET-S2");
function chg(){
var s1 = document.getElementById("s1");
var s2 = document.getElementById("s2");
var idx = s1.options[s1.selectedIndex].value;
for(var i = s2.options.length - 1; i >= 0; i --){
s2.remove(i);
}
for(var i = 0; i < arr[idx].length; i ++){
var opt = document.createElement("option");
s2.add(opt);
opt.innerText = arr[idx][i];
opt.value = arr[idx][i];
}
}
//-->
</SCRIPT>
</HEAD>
<BODY onload = "chg()">
专业:
<select onChange="chg()" name="s1" id="s1">
<option value="0">软件部</option>
<option value="1">网络部</option>
</select>
课程:
<select name="s2" id="s2">
</select>
</BODY>
</HTML>
和销毁元素
<SCRIPT LANGUAGE="JavaScript">
<!--
function kill(){
var img = document.getElementById("img");
if(img){
//img.removeNode(true);
document.body.removeChild(img);
//上面两种方法都可以删除图片,但第一种方法更直观.
}else{
alert("对不起,图片已删除");
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<input type="button" value="销毁" οnclick="kill();"><br>
<img id="img" src = "Creek.jpg">
</BODY>