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

PHP下拉复选框问题,求助!
代码如下:
<SELECT style="WIDTH: 180px;" name=DepartID>
  <OPTION value=ALL>全部门店</OPTION>
  <%
  TempSQL = "Select * From Sys_Depart Order By DepartID"
  Set TempRS = Server.CreateObject("ADODB.Recordset") 
  TempRS.Open TempSQL,conn,1,1  
  Do While Not TempRS.eof
  vID = TempRS("DepartID")
  vName = TempRS("DepartName")
  %>

  <%if vID = vDepartID then %>
  <OPTION value=<%=vID%> selected ><%=vName%></OPTION>
  <%else %>
  <OPTION value=<%=vID%>><%=vName%></OPTION>
  <%end if %>

  <%
  TempRS.MoveNext
  Loop  
  %>
  </SELECT>
请问该如何修改成选项前面可以打上小勾的复选框?

------解决方案--------------------
VBScript code

<input type="checkbox" name="DepartID" value="ALL">全部门店
  <%
  TempSQL = "Select * From Sys_Depart Order By DepartID"
  Set TempRS = Server.CreateObject("ADODB.Recordset")  
  TempRS.Open TempSQL,conn,1,1   
  Do While Not TempRS.eof
  vID = TempRS("DepartID")
  vName = TempRS("DepartName")
  if vID = vDepartID then %>
      vChecked = " checked=""checked"""
  else
      vChecked = "" 
  end if
%>
  <input type="checkbox" name="DepartID" value="<%=vID%>"<%=vChecked%>><%=vName%>
  <%
  TempRS.MoveNext
  Loop   
  %>