苏斯博士经典绘本图片:请问一下,这段代码哪里错了呀??

来源:百度文库 编辑:中科新闻网 时间:2024/04/25 06:02:27
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #00FF00}
.style3 {color: #FFFF00}
-->
</style>
<% dim bg
dim s
if s=1 then
bg="#FF0000"
if s=2 then
bg="#00FF00"
if s=3 then
bg="#FFFF00"
End if
%>
<table width="88" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="88" height="29" valign="top" bgcolor='bg'><!--DWLayoutEmptyCell--> </td>
</tr>
</table>
<table width="371" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="371" height="28" valign="top"><form name="form1" method="post" action="">
<span class="style1">红色</span>
<input type="radio" name="s" value="1">
<span class="style2">绿色</span>
<input type="radio" name="s" value="2">
<span class="style3">黄色</span>
<input type="radio" name="s" value="3">
</form></td>
</tr>
</table>
这个页面有三个单选,只要选择不同的选项,那个黑框就会变成相应的颜色。

<% dim bg
dim s
if s=1 then
bg="#FF0000"
if s=2 then
bg="#00FF00"
if s=3 then
bg="#FFFF00"
End if
%>
1 语法错误

if then

elseif then
......

end if
'//
你要的效果没说出来!我只能猜!

<%
mybg=request.form("s")
'//接收表单传出来的S的值
select case mybg
case 1
bg="#FF0000"
case 2
bg="#FFFF00"
case 3
bg="#FFFF00"
enn select
%>

你。。。。

我差点气得吐血也。。。。

让我差点晕死过去。。。。

我看了你的补充说明,了解,你根本用DHTML就可以办到的事,怎么非要加入个什么<%...%>,写成ASP的脚本??就算你要写成提交到服务器处理,你也让我再次的吐血——
你提交了,要在服务器读出,Response.form("XXX")一下啊,帅哥,
然后,你要显示出来,也得把它Response.write("...")

你什么都不做?!?!就想变色!!!

以下,是我用DHTML写好的代码,不经过服务器,你把以下部分保存到一个HTML文件。看看效果,再看看代码算好了。。。

-------代码开始---------
<table id="thename" width="88" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td width="88" height="29" valign="top">
</td>
</tr>
</table>
<table width="371" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="371" height="28" valign="top">
<script language="JavaScript">
function cgclr(obj)
{
window.document.all.thename.bgColor = obj.value;
}
</script>
<span class="style1">红色</span>
<input type="radio" name="s" value="#ff0000" onclick="cgclr(this)">
<span class="style2">绿色</span>
<input type="radio" name="s" value="#00ff00" onclick="cgclr(this)">
<span class="style3">黄色</span>
<input type="radio" name="s" value="#ffff00" onclick="cgclr(this)">
</td>
</tr>
</table>

---------代码结束---------

我用的方法是DHTML加JScript,你可以在网上查找下载这方面的参考 Dhtml, JavaScript。当然,客户端脚本你也可以用VBScript去写,你最好也下载个VBScript的参考看看。Goodluck