为什么<%if cars =“Volvo”然后Response.Write(“checked”)%>

时间:2013-08-25 11:51:02

标签: asp-classic

我是ASP的新手,我看到一个例子,但无法弄清楚为什么使用
<%if cars =“Volvo”then Response.Write(“checked”)%>

代码: - >

<!DOCTYPE html>
<html>
<%
dim cars
cars=Request.Form("cars")
%> 
<body>
<form action="demo_radiob.asp" method="post">
<p>Please select your favorite car:</p>

<input type="radio" name="cars"
<%if cars="Volvo" then Response.Write("checked")%>
value="Volvo">Volvo</input>
<br>
<input type="radio" name="cars"
<%if cars="Saab" then Response.Write("checked")%>
value="Saab">Saab</input>
<br>
<input type="radio" name="cars"
<%if cars="BMW" then Response.Write("checked")%>
value="BMW">BMW</input>
<br><br>
<input type="submit" value="Submit" />
</form>
<%
if cars<>"" then
Response.Write("<p>Your favorite car is: " & cars & "</p>")
end if
%>
</body>
</html>

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:2)

用于在输出为HTML时检查单选按钮。

以下是对已检查属性的详细说明 - http://www.w3schools.com/tags/att_input_checked.asp

response.write正在打印出字符串。这里有一个更详细的解释链接 - http://www.w3schools.com/asp/met_write_response.asp

HTH

瓦德