以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 移动开发,如何获取当前页某控件的值? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=129587) |
||||
-- 作者:ycwk -- 发布时间:2019/1/2 10:07:00 -- 移动开发,如何获取当前页某控件的值? 如下代码: Dim e As RequestEventArgs = args(0) Dim wb As New weui wb.AddForm("","form1","CheckPd.htm") \' .Attribute="" \' 由CheckPd接收提交的数据 With wb.AddInputGroup("form1","ipg1","设备资料") .AddInput("AssetNumber","资产编号","Text") \'前一个"AssetNumber"是ID,后一个"资产编号"是标题 End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1","确定","button").Attribute="" \'button千万不能写成submit,否则就会造成数据提交两遍 End With \'存在重复盘点记录时,给出是否重新盘点的提示. With wb.AddDialog("","dlg4", "重新盘点确认","您确定要对当前设备重新盘点吗?") .AddButton("btnCancel","取消").Kind = 1 .AddButton("btnOK","确定","./CheckPd.htm?AssetNumber=" & AssetNumber.value ) \'在此处想把控件ASsetNumber 的值做为get参数传递给下一页,请问要怎么获取用户输入的AssetNumber值?? End With wb.AppendHTML("<script src=\'./ajax/libs/pdScan.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build)
[此贴子已经被作者于2019/1/2 10:07:47编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2019/1/2 12:37:00 -- 绑定onclick事件,执行js,获取值,然后跳转到新的网页
location = "/CheckPd.htm?AssetNumber=" + AssetNumber.value [此贴子已经被作者于2019/1/2 12:37:09编辑过]
|
||||
-- 作者:ycwk -- 发布时间:2019/1/2 14:38:00 -- 老师,你可能没注意我的代码,流程是这样的,用户先输一个assetnumber,程序进行判断,如果已经存在这个号码了,则弹出dlg4,如果不存在,才直接跳转,如果绑定js,好像就实现不了这样的功能,我改成下面这样了,结果不行: Dim e As RequestEventArgs = args(0) Dim wb As New weui \' wb.AddForm("","form1","CheckPd.htm").Attribute="" \'checkpd.htm 是接收结果的页面 wb.AddForm("","form1","CheckPd.htm") \'.Attribute="" \' 由CheckPd接收提交的数据 With wb.AddInputGroup("form1","ipg1","设备资料") .AddInput("AssetNumber","资产编号","Text") \'前一个"AssetNumber"是ID,后一个"资产编号"是标题 End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1","确定","button").Attribute="" \'button千万不能写成submit,否则就会造成数据提交两遍 \' .Add("btnOK","继续","./CheckPd.htm?AssetNumber=" & "172.16.5.1" ) End With \'存在重复盘点记录时,给出是否重新盘点的提示. With wb.AddDialog("","dlg4", "重新盘点确认","您确定要对当前设备重新盘点吗?") .AddButton("btnCancel","取消").Kind = 1 .AddButton("btnOK","继续","./CheckPd.htm?AssetNumber=" & e.Cookies("AssetNumber") ) End With wb.AppendHTML("<script src=\'./ajax/libs/pdScan.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) pdscan.js 代码如下: //发送JSON对象 function pdScanFunction() { var result = submitAjaxForm(\'form1\',\'\',false); //false 表示同步执行 //如果正确跳出验证对话框,确定后转目标网页 如果不正确,则跳出对话框停留在该页。 if (result ==\'exist\') //查到重复盘点记录 { showDialog(\'dlg4\',\'!!!警告!!!\',\'发现存在重复盘点记录!\'); // show(\'dlg4\') return false; } else //可以正常记录盘点结果 { // showDialog(\'dlg3\'); // document.getElementById("p1").innerHTML=result; //在P1位置显示各字段内容 return true; } } function pdJumpFunction() { location = "/CheckPd.htm?AssetNumber=" + AssetNumber.value; } [此贴子已经被作者于2019/1/2 14:43:43编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2019/1/2 15:01:00 -- 【确定】按钮,绑定onclick事件,然后里面js代码,用2楼,或者调用pdJumpFunction函数。 |
||||
-- 作者:ycwk -- 发布时间:2019/1/2 15:36:00 -- 问题一: 按照老师说的,改了一下,现在点击按钮是正常的了,但是输入完后回车 直接跳转到“不存在数据”的新页面, 回车和点击按钮,能做成同样的效果吗? Dim e As RequestEventArgs = args(0) Dim wb As New weui \' wb.AddForm("","form1","CheckPd.htm").Attribute="" \'checkpd.htm 是接收结果的页面 wb.AddForm("","form1","CheckPd.htm") \'.Attribute="" \' 由CheckPd接收提交的数据 With wb.AddInputGroup("form1","ipg1","设备资料") .AddInput("AssetNumber","资产编号","Text") \'前一个"AssetNumber"是ID,后一个"资产编号"是标题 End With With wb.AddButtonGroup("form1","btg1",True) .Add("btnOK","确定","button").Attribute="" \'button千万不能写成submit,否则就会造成数据提交两遍 \'.Add("btnOK","继续","./CheckPd.htm?AssetNumber=" & "172.16.5.1" ) End With \'存在重复盘点记录时,给出是否重新盘点的提示. With wb.AddDialog("","dlg4", "重新盘点确认","您确定要对当前设备重新盘点吗?") .AddButton("btnCancel","取消").Kind = 1 .AddButton("btnOK","继续","./CheckPd.htm?AssetNumber=" & e.Cookies("AssetNumber") ) \' .AddButton("btnOK","继续","./CheckPd.htm?AssetNumber=" & "\'pdJumpFunction()\'" ) End With wb.AppendHTML("<script src=\'./ajax/libs/pdScan.js\'></script>") \'引入脚本文件 \' wb.AppendHTML("<script src=\'./ajax/libs/pdJump.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) checkpd.htm 代码如下: Dim e As RequestEventArgs = args(0) Dim wb As New weui \'wb.InsertHTML("<div data-theme=\'g\' data-role=\'page\' data-position=\'fixed\'>") \'页内容样式 wb.AppendHTML("<script src=\'./ajax/libs/pdResult.js\'></script>") \'引入脚本文件 \'msgbox(e.PostValues("AssetNumber")) \'msgbox(e.Cookies("AssetNumber")) 弹出为空的值 If e.PostValues.ContainsKey("AssetNumber") Then \' msgbox(e.PostValues("AssetNumber")) \'能弹出172.16.5.1 e.AppendCookie("AssetNumber",e.PostValues("AssetNumber")) \'增加cookie Dim dr As DataRow= DataTables("盘点记录").SQLFind("资产编号 = \'" & e.PostValues("AssetNumber") & "\'") If dr IsNot Nothing Then \'如果存在重复盘点记录的话 \'msgbox(e.PostValues("AssetNumber")) e.WriteString("exist") Else \'如果不存在重复记录的话,则直接把 AssetNumber带着跳转到 CheckPd 页面 \' wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'没有找到该记录则直接跳转到显示结果的页面 e.WriteString(e.PostValues("AssetNumber")) End If End If If e.GetValues.ContainsKey("AssetNumber") Then \'msgbox(e.GetValues("AssetNumber")) \'能弹出172.16.5.1 wb.DeleteCookie("AssetNumer") \'删除cookie Dim dr1 As DataRow= DataTables("资产管理表").SQLFind("IP地址 = \'" & e.GetValues("AssetNumber") & "\'") If dr1 IsNot Nothing Then \'如果资产管理表中有此资产编号对应的资料 wb.AddForm("","form1","PdResult.htm") With wb.AddInputGroup("form1","ipg1","请核对资料") .AddInput("zcmc","资产名称","text").Value=dr1("资产名称") .AddInput("zcgs","资产归属","text").Value=dr1("资产归属") .AddInput("cgxm","采购项目","text").Value=dr1("采购项目") \' .AddInput("pw","密码","password") End With With wb.AddButtonGroup("","btg1", False) \'水平排列的两个按钮 分组号为btg2 .Add("btnOK","显示正确").Attribute = "" .Add("btnWrong","显示错误").Attribute = "" End With e.WriteString(wb.Build) Else e.WriteString("不存在数据!") End If End If 问题二: 如何在打开 pdscan.htm 后,自动把焦点转置 文本输入框上面? [此贴子已经被作者于2019/1/2 15:58:36编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2019/1/2 16:15:00 -- 1、你输入值以后,按下回车,触发了哪个按钮的事件?你页面里有submit按钮?或者其余的事件?请做一个对一个例子发上来测试。全部文件都要打包在一起才能测试。
不然,请单独做一个可以简易测试的实例发上来测试。
2、如
Select Case e.Path |
||||
-- 作者:ycwk -- 发布时间:2019/1/2 16:31:00 --
除了数据库,都在上面了,数据库太大了,就用到两张表,表结构如下: |
||||
-- 作者:ycwk -- 发布时间:2019/1/2 16:32:00 -- 总共页面上就一个按钮,不会有别的按钮被触发吧 |
||||
-- 作者:有点甜 -- 发布时间:2019/1/2 16:46:00 -- 改成
With wb.AddInputGroup("form1","ipg1","设备资料")
当form表单中只有一个<input>时按回车键将会自动将表单提交
|
||||
-- 作者:ycwk -- 发布时间:2019/1/2 17:25:00 -- 另一个问题,我的pdResult.js 的代码如下: 但是 document.getElementById(\'zcmc\').value 获取到的值是乱码,这是怎么回事? function right(){ location="pdResult.htm?pdResult=" + "right" + "&zcmc=" + document.getElementById(\'zcmc\').value; //location="pdResult.htm?pdResult=" + "right" + "&zcmc=" + zcmc.value; //document.getElementById(\'dj\').value //location="list.htm?page=" + table1.pagenumber + "&deloid=" + table1.primarykey; //location="pdResult.htm?pdResult=" + "right"; } [此贴子已经被作者于2019/1/2 20:56:28编辑过]
|