以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  变量传递  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=107302)

--  作者:lshshlxsh
--  发布时间:2017/9/25 13:47:00
--  变量传递
Dim e As RequestEventArgs = args(0)
\'获取要显示的页
Dim page As Integer = 0 \'默认page为0,显示第一页
Dim pageRows As Integer = 3 \'每页10行
If e.GetValues.ContainsKey("page") Then  \'如果地址中有page参数
    Integer.TryParse(e.GetValues("page"), page) \'提取page参数
End If
Dim StartRow As Integer = page * pageRows + 1 \'此页第一行
Dim EndRow As Integer = (page + 1) * pageRows \'此页最后一行
\'获取该页数据
Dim Count As Integer =DataTables("订单").SQLCompute("Count(*)", "")
Dim dt As DataTable = DataTables("订单")

Dim wb As New WeUI
With wb.AddTable("","Table1")
    .PageNumber = page \'设置页码
    .Primarykey = "Identify" \'设置主键
    \'\' .ActiveSheet = "menu" \'设置菜单
    .CreateFromDataTable(dt)
End With

Dim aa As String
For Each dr As DataRow  In dt.datarows
    aa = aa &  " or Identify=\'" &  dr("_Identify") & "\'"
Next
aa ="(" & aa.Trim("o","").Trim("r","")   & ")"
messagebox.show( aa )

\'根据此页数据生成网页
With wb.AddButtonGroup("","btg1" ) \'生成上一页和下一页按钮
    .Add("btn1","删除").Attribute =""
    .Add("btn1","aa").Attribute ="""
End With

wb.AppendHTML("<script src=\'./lib/table.js\'></script>") \'引入脚本文件
e.WriteString(wb.Build)







请问一下 怎么把变量 aa 传递到js 页面?

js 代码
function del(){

alert(table1.primarykey);
    if(table1.primarykey){
        location="delete.htm?page=" + table1.pagenumber + "&key=" + table1.primarykey; 
    }
}


不选中行的情况下怎么删除当页显示的所有内容?
[此贴子已经被作者于2017/9/25 13:50:15编辑过]

--  作者:有点甜
--  发布时间:2017/9/25 14:50:00
--  

1、 .Add("btn1","aa").Attribute ="onclick=""abc(\'" & aa & "\')"""

 

js函数

 

function abc(s) {

    alert(s)

}

 

2、参考1,判断 table1.primarykey 的值,如果没有值,那就写 location="delete.htm?page=" + table1.pagenumber + "&key=" + s

[此贴子已经被作者于2017/9/25 14:52:25编辑过]

--  作者:lshshlxsh
--  发布时间:2017/9/25 15:27:00
--  
谢谢老师 

 .Add("btn1","aa").Attribute ="onclick=""abc(\'" & aa & "\')"""


点击后能输出    or Identify=177 or Identify=172 or Identify=171

 

但是  

function abc(s) {

    alert(s);

}

 


弹出 s 空白

[此贴子已经被作者于2017/9/25 15:50:19编辑过]

--  作者:有点甜
--  发布时间:2017/9/25 15:49:00
--  
代码没问题,我测试代码没问题,能正确弹出aa值。
--  作者:lshshlxsh
--  发布时间:2017/9/25 15:55:00
--  


[此贴子已经被作者于2017/9/25 16:16:34编辑过]

--  作者:有点甜
--  发布时间:2017/9/25 16:05:00
--  

如下代码测试没问题

 

Select Case e.path
    Case "test.htm"
        Dim wb As New weui
        wb.AddForm("","form1","test.htm")
        With wb.AddButtonGroup("form1","ipg1")
            Dim aa As String = "123456"
            .Add("btn1","aa").Attribute ="onclick=""abc(\'" & aa & "\')"""
        End With
        wb.AppendHTML("<script src=\'./lib/test.js\'></script>") \'引入脚本文件
        e.WriteString(wb.Build) \'生成网页
End Select