0
不完全确定如何搜索这个问题,我已经与VBScript,所以请原谅,如果这是重复的。VBScript For Loop不执行if语句?
我有一个功能,可以在需要2个参数的页面上打印分页,totalpgs
和active
。我的问题是,当变量pg
是不是集时,active
页面仅适用链接上的样式。我很确定这是一个逻辑问题,但我一直盯着这个已经7天了。
下面是函数:
'======= Print Pagination links
function print_pagination (totalpgs,active)
p = "<div class=""row"">"
p = p & "<div class=""pagination pagination-right"">"
p = p & "<ul>"
for x = 1 to totalpgs
if x = active then
li = "<li class=""active"">" '<- Set class for current page
else
li = "<li>" '<- else regular link
end if
p = p & li & "<a href='?pg="& x &"'>"& x &"</a></li>"
next
p = p & "</ul></div></div>"
print_pagination = p
end function
这里是网页上的代码:
pg = request.querystring("pg")
if pg = "" then
pg = 1
end if
<%=print_pagination(totalpages,pg) %>
这里是理想的结果:
我想目前的<li>
包含一个名为的类。
这是发生了什么:
的active
类从未被应用到<li>
标签。当url包含pg
的get变量时,不会分配任何活动的类。如果没有,则应用到第一个链接。
这是它!谢谢。 – ckpepper02