<%
thetext1=request("text1")
yanse=request("color")
huayu="<font color="&yanse&">"&thetext1&"</font>"
theliaotian= session("thename")&"说:"&huayu&"<br>"
application.lock()
application("liaotian")=application("liaotian")+theliaotian
application.unlock()
%>
<body>
<form name="form1" method="post" action="shuru.asp">
<input type="text" name="text1">
<select name="color">
<option value="black" selected>黑色</option>
<option value="red">红色</option>
<option value="blue" >蓝色</option>
</select>
<input type="submit" name="Submit" value="提交" >
</form>
其中huayu="<font color="&yanse&">"&thetext1&"</font>"
这句代码中color="&yanse&"
为什么要加""和&&
不是已经接收了列表框的颜色值了吗?
參考答案:yanse是变量,是接收了表单的输入值,但它前后都是HTML代码,所以用字符串连接符&连接起来。
至于双引号,那是ASP中字符串起始和终止所必须的,相当于定界符。