【问题标题】:hidding table rows classic asp隐藏表行经典asp
【发布时间】:2011-07-12 15:34:53
【问题描述】:

我在我的网页上使用分页,因此对于我按下的每个字母,它都会显示以该字符开头的记录。但是我的问题是我需要使用 # 来显示除字符之外的所有内容,以便它包含以例如 - 1、323、_、!等开头的记录。我将如何使用正则表达式来比较值,例如 -

if left(selectedRecord, 1) <> "[^a-z]" then

我曾经使用存储过程来执行此操作,但由于分页时复选框有问题,我只是提取所有记录并像这样过滤 -

response.Write "<tr"
if trim(request.Form("selected_Button")) = "#" then

elseif trim(request.Form("selected_Button")) <> lcase(trim(left(objRS("Movies"), 1))) and len(request.Form("selected_Button")) = 1 then
    response.Write " style=""display:none;"""

end if
response.Write ">"

所以我的问题是如何修复我在存储过程中使用的 # -

select * from Movies where movies like '[^a-z]%'

分页按钮 -

<center><input id="buttonStyle" type="submit" name="Selected_Button" value="#">
    <% for i = 97 to 122 %>
         <input id="buttonStyle" type="submit" name="Selected_Button" value="<%=CHR(i) %>">&nbsp;
    <% next %></center>
<center></br><input id="buttonStyle" type="submit" name="Selected_Button" value="View All"></center>

编辑

所以我自己找到了一个解决方案,但我想知道我是否可以在不遍历字母表的情况下做到这一点 -

response.Write "<tr"
if trim(request.Form("selected_Button")) = "#" then
    for i = 97 to 122 
        if lcase(trim(left(objRS("Movies"), 1))) = chr(i) then
            response.Write " style=""display:none;"""
        end if
    next
elseif trim(request.Form("selected_Button")) <> lcase(trim(left(objRS("Movies"), 1))) and len(request.Form("selected_Button")) = 1 then
    response.Write " style=""display:none;"""

end if
response.Write ">"

【问题讨论】:

    标签: html regex vbscript asp-classic pagination


    【解决方案1】:

    您在这里实际上要问的是“如何识别第一个字符是字母?”答案是替换这个循环:

    for i = 97 to 122 
        if lcase(trim(left(objRS("Movies"), 1))) = chr(i) then
            response.Write " style=""display:none;"""
        end if
    next
    

    用这个代替:

    firstChar = Left(UCase(Trim(objRS("Movies"))), 1)
    If firstChar>="A" And firstChar<="Z" Then
        response.Write " style=""display:none;"""
    End If
    

    简单的比较就可以了。

    【讨论】:

      【解决方案2】:

      我的修改将解决这个问题 -

      response.Write "<tr"
      if trim(request.Form("selected_Button")) = "#" then
          for i = 97 to 122 
              if lcase(trim(left(objRS("Movies"), 1))) = chr(i) then
                  response.Write " style=""display:none;"""
              end if
          next
      elseif trim(request.Form("selected_Button")) <> lcase(trim(left(objRS("Movies"), 1))) and len(request.Form("selected_Button")) = 1 then
          response.Write " style=""display:none;"""
      
      end if
      response.Write ">"
      

      【讨论】:

        猜你喜欢
        • 2011-12-06
        • 1970-01-01
        • 2019-10-29
        • 1970-01-01
        • 1970-01-01
        • 2012-01-24
        • 2015-05-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多