首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > vbScript >

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

2012-02-05 
跪求高手vbscript转javascript小生不才,想在ASP中使用FlexiGrid,好不容易在网上找了一个asp的DEMO,但是vbs

跪求高手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)%>']}


<%
'Add Comma To End Of JSON Line If It Isn't The Last Record  
RecordsetXML.movenext
If Not RecordsetXML.eof Then
  Response.Write ","
End If
loop
End if
%>

]}

<%
RecordsetXML.Close()
Set RecordsetXML = Nothing
%>

[解决办法]
检查你的客户端html 代码是否符合js语法
[解决办法]
唉 可惜只会点vbscript js还不太会。。。

热点排行