最近学习网页动态设计,自己用的书讲到vbscript,编了一个网页,没想到,不光保存后网页显示有错误,而且根本就没有按照预定的目的实现,自己检查了好几次,也没有弄出来,同学推荐这个论坛。就来问问了!希望有高手能指点一下。谢谢!
下面是我的源代码,按照预定的目的,应该是点那四个颜色按键,点哪一个颜色,网页背景颜色就是那种颜色,可是现在一刷新网页,就出现script err,不知是怎么回事?望有高手能指点一下!谢谢!
<html>
<head>
<title>if...then语句的使用</title>
<script language="vbscript">
<!--
sub bchange(choice)
if choice=1 then document.bgcolor="red"
else if choice=2 then document.bgcolor="yellow"
else if choice=3 then document.bgcolor="blue"
else document.bgcolor="green"
end if
end sub
-->
</script>
</head>
<body>
<center>
<h2><font color=red>文字和背景颜色的选择</font></h2>
<p>
<table border=2>
<tr><th>背景颜色<th>选择<th>文字颜色<th>选择</tr>
<tr><td>红色<td><input type=radio onclick="bchange(1)">
<td>黄色<td><input type=radio onclick="bchange(2)"></tr>
<tr><td>蓝色<td><input type=radio onclick="bchange(3)"></tr>
<td>绿色<td><input type=radio onclick="bchange(4)"></tr>
</table>
</center>
</body>
</html>
<script language="vbscript">
<!--
sub bchange(choice)
if choice=1 then
document.bgcolor="red"
elseif choice=2 then document.bgcolor="yellow"
elseif choice=3 then document.bgcolor="blue"
else document.bgcolor="green"
end if
end sub
-->
</script>
1,多行的if then 语句换行
2,elseif 连写