日期:2014-05-17  浏览次数:21068 次

高手大哥,出来练练手吧,一个判断的写法不会了,哪位大哥帮忙看一下?
<option   value= ' <%=krs( "gsid ")%> '     <%if   krs( "公司名称old ")=search   then   response.write   "selected "     end   if%> > <%=krs( "公司名称old ")%> </option>

这是原来一个select选项值的写法,现在由于需要可能会有二种情况,isno= "1 "或是isno= "2 ",当isno= "1 ",这个选项值的写法是:
<option   value= ' <%=krs( "gsid ")%> '     <%if   krs( "公司名称old ")=search   then   response.write   "selected "     end   if%> > <%=krs( "公司名称old ")%> </option>

当isno= "2 "时,其会对应另个一个查询,相应的字段值会发生改变,写法如下:
<option   value= ' <%=krs( "zyid ")%> '     <%if   krs( "公司名称zy ")=search   then   response.write   "selected "     end   if%> > <%=krs( "公司名称zy ")%> </option>

如何把这二种情况整合到这一句中去啊,理不清楚了,写不出来了

------解决方案--------------------
应该可以这样吧
<%if isno=1 then%>
<option>
<%elseif isno=2 then%>
<option>
<%end if%>

------解决方案--------------------
什么叫整合到一句中?
select case isno
case "1 "
<option value= ' <%=krs( "gsid ")%> ' <%if krs( "公司名称old ")=search then response.write "selected " end if%> > <%=krs( "公司名称old ")%> </option>
Case "2 "
<option value= ' <%=krs( "zyid ")%> ' <%if krs( "公司名称zy ")=search then response.write "selected " end if%> > <%=krs( "公司名称zy ")%> </option>
end select
这样不行吗?你自己都写出来了嘛……

或者你说的是这样:
<option
<%if isno= "1 " then%>
value= ' <%=krs( "gsid ")%> ' <%if krs( "公司名称old ")=search then response.write "selected " end if%> > <%=krs( "公司名称old ")%>
<%elseif isno= "2 " then%>
value= ' <%=krs( "zyid ")%> ' <%if krs( "公司名称zy ")=search then response.write "selected " end if%> > <%=krs( "公司名称zy ")%>
<%end if%>
</option>
但这样写太乱了,自己看着也累啊。
------解决方案--------------------
<%
if isno= "1 " then
zd=krs( "gsid ")
zd1=krs( "公司名称old ")
else
zd=krs( "zyid ")
zd1=krs( "公司名称zy ")
end if
%>
<option value= ' <%=zd%> ' <%if zd1=search then response.write "selected " end if%> > <%=zd1%> </option>