0

我在数据库中将检查值作为逗号分隔值。当下次用户访问该页面时,我需要显示逗号分隔值中的检查值,以便用户可以更新它们并再次提交它们。这是我的代码:/ ArrayValues="PMT/HLBRs,ROM,Development"(这里没有放数据库部分) /

     ArrayValues=Split(objRSComment.fields("Phase"),",")
     for i=0 to 8 
     Response.Write "Value " & i & " is " & ArrayValues(i) & "<br>"
     Next 
     response.end() 
     <input type="checkbox" name="chkProjPhase" value="PMT/HLBRs"  "checked"/><label>PMT/HLBRs</label>
     <input type="checkbox" name="chkProjPhase" value="ROM" "checked"/><label>ROM</label>
     <input type="checkbox" name="chkProjPhase" value="BUS CASE APPROVAL" <%=chkVal% >/><label>BUS CASE APPROVAL</label> 
     <input type="checkbox" name="chkProjPhase" value="Detailed Requirements" /><label>Detailed Requirements</label>
     <input type="checkbox" name="chkProjPhase" value="20% LOE"/><label>20% LOE</label>
     <input type="checkbox" name="chkProjPhase" value="Development"/><label>Development</label>
     <input type="checkbox" name="chkProjPhase" value="Testing"/><label>Testing</label>
     <input type="checkbox" name="chkProjPhase" value="Implementation"/><label>Implementation</label>
     <input type="checkbox" name="chkProjPhase" value="Post Deployment Monitoring"/><label>Post Deployment Monitoring</label>

我必须显示“PMT/HLBRs,ROM,Development”这些值在复选框和其他未选中的情况下选中。

4

1 回答 1

0

你可以做一个简单的字符串搜索

<%
dim phaseList = objRSComment.fields("Phase")

function isChecked(phase)
   dim retVal = ""

   if inStr(phaseList, phase) > 0 then  
      retval = " checked "  
   end if
   isChecked = retVal

end function

ArrayValues=Split(objRSComment.fields("Phase"),",")
     for i=0 to 8 
     Response.Write "Value " & i & " is " & ArrayValues(i) & "<br>"
     Next 
%>
     <input type="checkbox" name="chkProjPhase" value="PMT/HLBRs" <%= isChecked("PMT/HLBRs") %>/><label>PMT/HLBRs</label>
     <input type="checkbox" name="chkProjPhase" value="ROM" <%= isChecked("ROM") %>/><label>ROM</label>
     ... etc
     <input type="checkbox" name="chkProjPhase" value="Post Deployment Monitoring" <%= isChecked("Post Deployment Monitoring") %>/><label>Post Deployment Monitoring</label>

请注意 ,如果您有从彼此派生的阶段,这将无法按预期工作。即,如果您有诸如housing和之类的阶段housing loans,如果房屋贷款在阶段列表中,则将检查房屋

于 2013-08-27T06:58:52.970 回答