开发者

hidding table rows classic asp

I'm using paging on my webpage, so for each letter I press it would display records starting with that character. However my problem is that I need to use # to display everything but characters, so that it will include records that begin with e.g - 1, 323, _, !, etc. How would I use a regular expression to compare values like say -

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

I used to use a store procedure to do this but because checkboxes are problematic when paging I just pull all records and filter like this -

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 ">"

So my question is how would I fix the # as I used in my stored procedure -

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

Paging Buttons -

<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>

EDIT:

So i found a solution myself but i want to kn开发者_开发技巧ow if i can do this without looping through the alphabet -

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 ">"


What you actually ask here is "how to identify the first character is a letter?" and the answer is replace this loop:

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

With this instead:

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

Simple comparison will work just fine.


My edit will fix this problem -

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 ">"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜