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

一个难题,asp判断语句不执行怎么办?
<%
set   rs=Server.CreateObject( "ADODB.Recordset ")
sql= "select   daoshi_yiji   from   [daima]   where   daoshi_yiji   is   not   null   order   by   id   asc "
rs.open   sql,conn,1,1
for   x=1   to   rs.recordcount
daoshi_yiji_edit   =   daoshi_yiji_edit   &   " <option   value= "&rs( "daoshi_yiji ")&   "   <%   if   ds_yjxk   = "   &   rs( "daoshi_yiji ")   &   "   then   response.write   'selected '   %\> "   &   rs( "daoshi_yiji ")   &   " </option> "
rs.movenext
next
rs.close
application( "daoshi_yiji_edit ")                 =   daoshi_yiji_edit               '一级学科
%>
上面生成了application( "daoshi_xueli_edit ")   ,只是生成了一个select表单的选项信息,但特别之处是其中又包含了一个asp的判断语句。

然后在edit页面调用这个application( "daoshi_xueli_edit "),方法如下:

<%
sql= "select   *   from   [daoshiok]   where   id= "&dbid
rs.open   sql,conn,1,1
ds_yjxk     =     rs( "ds_yjxk ")%>
<td   colspan= "2 ">
<select   size= "1 "   name= "ds_yjxk "   style= "width:100%; ">
<option   value= " "   > 请选择 </option>
<%=application( "daoshi_yiji_edit ")%>
</select>

为什么可以生成select列表,但是其中的asp判断语句不执行呢??

------解决方案--------------------
自己的写法错误~!

for x=1 to rs.recordcount
daoshi_yiji_edit = daoshi_yiji_edit & " <option value= "&rs( "daoshi_yiji ")
if ds_yjxk = rs( "daoshi_yiji ") then
daoshi_yiji_edit = daoshi_yiji_edit & " selected "
end if
daoshi_yiji_edit = daoshi_yiji_edit & "> " & rs( "daoshi_yiji ") & " </option> "
rs.movenext
------解决方案--------------------
daoshi_yiji_edit = daoshi_yiji_edit & " <option value= "&rs( "daoshi_yiji ")
if ds_yjxk = " & rs( "daoshi_yiji ") & " then
daoshi_yiji_edit=daoshi_yiji_edit+“selected”
end if
daoshi_yiji_edit=daoshi_yiji_edit+ rs( "daoshi_yiji ") & " </option> "
------解决方案--------------------
daoshi_yiji_edit = daoshi_yiji_edit & " <option value= "&rs( "daoshi_yiji ")& " <% if ds_yjxk = " & rs( "daoshi_yiji ") & " then response.write 'selected ' %\> " & rs( "daoshi_yiji ") & " </option> "

改為

if ds_yjxk =rs( "daoshi_yiji ") then
daoshi_yiji_edit = daoshi_yiji_edit& " <option selected value= "&rs( "daoshi_yiji ")& "> "&rs( "daoshi_yiji ") & " </option> "
else
daoshi_yiji_edit = daoshi_yiji_edit& " <option value= "&rs( "daoshi_yiji ")& "> "&rs( "daoshi_yiji ") & " </option> "
end if
------解决方案--------------------