经典asp显示复选框中的逗号分隔值的值

时间:2013-08-27 06:35:39

标签: asp-classic

我在数据库中将选中的值作为逗号分隔值。当用户下次访问页面时,我需要显示逗号分隔值的选中值,以便用户可以更新它们并再次提交它们。 这是我的代码: / 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 / HLBR,ROM,开发”这些值,而不检查其他值。

1 个答案:

答案 0 :(得分: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>

警告如果您的相位来自彼此,则无法按预期工作。即如果您有housinghousing loans等阶段,将检查住房贷款是否在阶段列表中