欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

跪求高手vbscript转javascript,该如何解决

更新时间: 2014-01-05 01:53:09 责任编辑: Author_N1

 

跪求高手vbscript转javascript
小生不才,想在ASP中使用FlexiGrid,好不容易在网上找了一个asp的DEMO,但是vbscript的,不怎么懂,试着改了一下,没成功,希望各位XDJM帮我一把,谢谢!!!!

vbscript

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/connection.asp" -->
<%
'Cleanup Function For JSON Code
Function cleanup(n)
varName = n
if varName > "" then
varName = Replace(varName, " ", "_")
Set r = New RegExp
r.IgnoreCase = True
r.Global = True
r.pattern = "[^\w_]"
varName = r.replace(varName, "")
varName = Replace(varName, "_", " ")
cleanup = varname
End If
End Function

'Check The Page Number
Dim page
page = Request.Form("page")
if page = "" then 
page = 1
End if

'Check The Amount Of Records Per Page
Dim rp
rp = Request.Form("rp")
if rp = "" then
rp = 15
End if

'Check What Page To Start On
Dim start
start = ((page-1) * rp)

'Set The Limit For The Query
limit = " TOP "&page*rp 

'What Column Did They Sort By?
Dim sortname
if Request.Form("sortname") = "" then
sortname = "id" 
Else
sortname = Request.Form("sortname")
End If

'Is Sorting ASC or DESC?
Dim sortorder
if Request.Form("sortorder") = "" then
sortorder = "desc"
Else
sortorder = Request.Form("sortorder")
End If
Dim sort 
sort = " ORDER By "&sortname&" "&sortorder

'Check For Searching
Dim searchterm
if Request.Form("query") <> "" then
searchterm = Request.Form("query")
searchcols = request.Form("qtype")
if searchcols = "id" then
if isnumeric(searchterm) then
fullsearch = " WHERE " & searchcols & " = " & searchterm & ""
else
fullsearch = " WHERE " & searchcols & " = 56465453143613645641564643156136135136561345643654"
End if
Else
fullsearch = " WHERE " & searchcols & " LIKE '%" & searchterm & "%'"
End if
End if

'Main Query
Dim RecordsetXML
Dim RecordsetXML_cmd
Dim RecordsetXML_numRows

Set RecordsetXML_cmd = Server.CreateObject ("ADODB.Command")
RecordsetXML_cmd.ActiveConnection = MM_MobliqConn_STRING
RecordsetXML_cmd.CommandText = "SELECT "& limit &" * FROM person"&fullsearch&""&sort

RecordsetXML_cmd.Prepared = true

Set RecordsetXML = RecordsetXML_cmd.Execute
RecordsetXML_numRows = 0

'Count The Amount Of Records Returned
Dim RecordsetXML2
Dim RecordsetXML2_cmd
Dim RecordsetXML2_numRows

Set RecordsetXML2_cmd = Server.CreateObject ("ADODB.Command")
RecordsetXML2_cmd.ActiveConnection = MM_MobliqConn_STRING
RecordsetXML2_cmd.CommandText = "SELECT count(*) as countR FROM person"&fullsearch
RecordsetXML2_cmd.Prepared = true

Set RecordsetXML2 = RecordsetXML2_cmd.Execute
RecordsetXML2_numRows = 0

Dim total
Dim countRec
total = RecordsetXML2.Fields.Item("countR").Value

RecordsetXML2.Close()
Set RecordsetXML2 = Nothing

'Generate JSON
%>
{
page: <%=page%>,
total: <%=cstr(total)%>,
rows: [

<%
if RecordsetXML.EOF then 

Else
RecordsetXML.Move start 
do until RecordsetXML.eof
%>
{id:'<%=(RecordsetXML.Fields.Item("id").Value)%>', cell:['<%=(RecordsetXML.Fields.Item("id").Value)%>', '<%=(RecordsetXML.Fields.Item("firstname").Value)%>','<%=(RecordsetXML.Fields.Item("lastname").Value)%>','<%=(RecordsetXML.Fields.Item("color").Value)%>','<%=(RecordsetXML.Fields.Item("height").Value)%>','<%=(RecordsetXML.Fields.Item("middlename").Value)%>','<%=(RecordsetXML.Fields.Item("age").Value)%>','<%=(RecordsetXML.Fields.Item("sex").Value)%>','<%=(RecordsetXML.Fields.Item("address1").Value)%>','<%=(RecordsetXML.Fields.Item("address2").Value)%>','<%=(RecordsetXML.Fields.Item("address3").Value)%>','<%=(RecordsetXML.Fields.Item("address4").Value)%>','<%=(RecordsetXML.Fields.Item("address5").Value)%>','<%=(RecordsetXML.Fields.Item("country").Value)%>','<%=(RecordsetXML.Fields.Item("region").Value)%>','<%=(RecordsetXML.Fields.Item("is_dead").Value)%>']}
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 01:53:09
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/2546/
本文WWW.DOC100.NET DOC100.NET版权所有。