如何在ASP中有条件地检查请求

时间:2011-09-18 08:19:24

标签: html asp-classic

我的ASP html以下

<div id="divCheckAll">
    <div class="selectall">
        <input type="checkbox" id="chkOperationalUpdate" name="chkOperationalUpdate" value="1" />
        Operational Update
        <div class="clear">
        </div>
    </div>
    <br />
    <div class="selectall">
        <input type="checkbox" id="chkLounges" name="chkLounges" value="1" />
        Lounges
        <div class="clear">
        </div>
    </div>
    <br />
    <div class="selectall">
        <input type="checkbox" id="chkLocations" name="chkLocations" value="1" />
        Locations
        <div class="clear">
        </div>
    </div>
    <br />
    <div class="selectall">
        <input type="checkbox" id="chkChauffeurdrive" name="chkChauffeurdrive" value="1" />
        Chauffeurdrive
        <div class="clear">
        </div>
    </div>
    <br />
    <div class="selectall">
        <input type="checkbox" id="chkFleet" name="chkFleet" value="1" />
        Fleet
    </div>
</div>

现在,在我的按钮单击和表单操作上,我正在调用另一个ASP页面,该页面将html值作为请求。我想检查上面的复选框是否未被选中,然后它会返回一些消息,如下所示:

If Request("chkOperationalUpdate")="" or Request("chkLounges")="" or Request("chkLocations")="" or Request("chkChauffeurdrive")="" or Request("chkFleet")="" Then    
    Response.Write "<font color='red'>Please select at least one items to be published</font>"
    Response.End
End If

以上条件适用于检查一个请求,但我想如果用户选择了任何复选框,那么它不应该返回任何消息,只有当用户错过了选择任何复选框时它才会返回消息。

请建议!!

1 个答案:

答案 0 :(得分:0)

or替换为and,这样,如果用户未选择,则会显示选择至少一个CheckBox的消息。

'none of the checkbox is selected
If Request("chkOperationalUpdate")="" and Request("chkLounges")="" and Request("chkLocations")="" and Request("chkChauffeurdrive")="" and Request("chkFleet")="" Then    
    Response.Write "<font color='red'>Please select at least one items to be published</font>"
    Response.End
Else
    'User has selected atleast one checkbox
End If