以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]判断web上点击某个按键?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=159246)

--  作者:枫白羽
--  发布时间:2020/12/18 15:05:00
--  [求助]判断web上点击某个按键?
蓝老师,你好!
请问一下,我在网页上放两个按键,点击这两个按键分别处理不同的事情
如果用If判断的话,怎么加这个判断点击的是哪个按键呢?

--  作者:linyunu1
--  发布时间:2020/12/18 15:11:00
--  
http://www.foxtable.com/mobilehelp/topics/0122.htm
--  作者:有点蓝
--  发布时间:2020/12/18 15:11:00
--  
With wb.AddButtonGroup("form1","btngrp1",False)
    .Add("btn1", "主页1","", "index.htm?id=1")
    .Add("btn2", "主页2","", "index.htm?id=2")
End With
With wb.AddButtonGroup("form1","btngrp2",False)
    .Add("btn3", "主页3", "button").Attribute = "onclick=""xx函数(\'1\')"""
    .Add("btn4", "主页4", "button").Attribute = "onclick=""xx函数(\'2\')"""
End With
With wb.AddButtonGroup("form1","btngrp1",False)
    .Add("btn5", "主页5","", "index.htm").value = "1"
    .Add("btn6", "主页6","", "index.htm").value = "2"
End With

--  作者:枫白羽
--  发布时间:2020/12/18 15:37:00
--  
蓝老师,是这样的
我两个按键点击提交,对应不同的结果,提交后还是返回当前页面
代码如下:

        With wb.AddButtonGroup("","qaqueryq",False)    
            If Modify = False Then
                \'.Add("qasamplings", "抽验", "")
                .Add("qasamplingok", "OK", "")
                .Add("qasamplingng", "NG", "")
            Else 
                \'.Add("qasamplings", "抽验", "", "qaclickpage.htm").Attribute= "onclick =  \'dataqueryshows()\'"
                .Add("qasamplingok", "OK", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows()\'".
                .Add("qasamplingng", "NG", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows()\'"
            End If
        End With

        \'\'\'Insert sample test data
        Dim snums As String = e.Cookies("snumbe")          \'\'\'Serial number(pcba号&包装号)
        Dim samplok As String = "OK"                       \'\'\'Sample results OK
        Dim samplng As String = "NG"                       \'\'\'Sample results NG

        Dim CurrentTimes As DateTime = Now
        \'msgbox("序号:" & snums & " 抽验结果:" & samplere)

        Dim qatable As String = "`TBL_" & jixing &  "_QA_TestLog`"    
        Dim conninsert As String = "INSERT INTO " & qatable & " (Barcode_SN, StartTime, QA_CheckResult) VALUES (\'" & snums & "\', \'" & CurrentTimes & "\', \'" & samplok & "\');"
        Dim conninserts As String = "INSERT INTO " & qatable & " (Barcode_SN, StartTime, QA_CheckResult) VALUES (\'" & snums & "\', \'" & CurrentTimes & "\', \'" & samplng & "\');"
        Dim DtConinsert As New System.Data.DataTable
        \'try                       
            If  Then
                DtConinsert = QueryReturnValue.ResultValue(conninsert, conn)
            Else
                DtConinsert = QueryReturnValue.ResultValue(conninserts, conn)
            End If


这个If 判断,该怎么判断点击哪个按键?


--  作者:有点蓝
--  发布时间:2020/12/18 15:39:00
--  
dataqueryshows函数代码发上来
                .Add("qasamplingok", "OK", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows(""1"")\'".
                .Add("qasamplingng", "NG", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows(""2"")\'"

--  作者:枫白羽
--  发布时间:2020/12/18 15:42:00
--  
function dataqueryshows(){
let data = $("#milltype").val()     //变量赋值给data——机型
$.cookie(\'data\',data)
console.log(data)
let snumbe = $("#number").val() //这个变量赋值给snumbers
$.cookie(\'snumbe\', snumbe)
console.log(snumbe)

     var result = submitAjaxForm(\'qasampling1\',\'\',false);
    document.getElementById("qasmaquery").innerHTML=result;
}

--  作者:有点蓝
--  发布时间:2020/12/18 15:51:00
--  
function dataqueryshows(id){
……

     var result = submitAjaxForm(\'qasampling1?id=\' + id,\'\',false);
……
}

服务端使用e.getvalues("id")获取根据不同值做判断

--  作者:枫白羽
--  发布时间:2020/12/18 16:38:00
--  
蓝老师,功能实现了,但是感觉哪里不太对

代码如下:


        With wb.AddButtonGroup("","qaqueryq",False)    
            If Modify = False Then
                .Add("qasamplingok", "OK", "")
                .Add("qasamplingng", "NG", "")
            Else 
                \'.Add("qasamplings", "抽验", "", "qaclickpage.htm").Attribute= "onclick =  \'dataqueryshows()\'"
                .Add("qasamplingok", "OK", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows(1)\'"
                .Add("qasamplingng", "NG", "", "qasampling.htm").Attribute= "onclick =  \'dataqueryshows(2)\'"
            End If
        End With

        \'\'\'Insert sample test data
        Dim snums As String = e.Cookies("snumbe")          \'\'\'Serial number(pcba号&包装号)
        Dim samplok As String = "OK"                       \'\'\'Sample results OK
        Dim samplng As String = "NG"                       \'\'\'Sample results NG

        Dim CurrentTimes As DateTime = Now
        \'msgbox("序号:" & snums & " 抽验结果:" & samplere)

        Dim qatable As String = "`TBL_" & jixing &  "_QA_TestLog`"    
        Dim conninsert As String = "INSERT INTO " & qatable & " (Barcode_SN, StartTime, QA_CheckResult) VALUES (\'" & snums & "\', \'" & CurrentTimes & "\', \'" & samplok & "\');"
        Dim conninserts As String = "INSERT INTO " & qatable & " (Barcode_SN, StartTime, QA_CheckResult) VALUES (\'" & snums & "\', \'" & CurrentTimes & "\', \'" & samplng & "\');"
        Dim DtConinsert As New System.Data.DataTable

        Dim qas = e.Cookies("id") 
        msgbox(qas)
        \'try                       
            If qas = 1 Then
                DtConinsert = QueryReturnValue.ResultValue(conninsert, conn)
            Else
                DtConinsert = QueryReturnValue.ResultValue(conninserts, conn)
            End If



js里的代码:

function dataqueryshows(id){
let data = $("#milltype").val()     //变量赋值给data——机型
$.cookie(\'data\',data)
console.log(data)
let snumbe = $("#number").val() //这个变量赋值给snumbers
$.cookie(\'snumbe\', snumbe)
console.log(snumbe)
$.cookie(\'id\', id)
console.log(id)
     var result = submitAjaxForm(\'qasampling1?id=\' + id,\'\',false);
document.getElementById("qasmaquery").innerHTML=result;
}


劳烦帮忙看看是哪里的问题



--  作者:有点蓝
--  发布时间:2020/12/18 16:40:00
--  
照抄5楼代码
--  作者:枫白羽
--  发布时间:2020/12/18 16:47:00
--  
5楼,7楼都照抄了,跟预想效果不一样