欢迎光临
我们一直在努力

在浏览器里实现类似VB Form的界面控制

建站超值云服务器,限时71元/月

在浏览器里很容易实现类似vb form的文本框,按钮等控制
主要用到 keydown,keyup,keypress 等事件
对按键的捕获使用 window 对象的子对象 event 的 keycode 属性
以下代码仅供参考:

<%@ language=vbscript %>
<%   by chen kang
     any problem please email to
     chenkang@chenkang.com
     vi 6.0 scripting object model enabled %>
<!–#include file="_scriptlibrary/pm.asp"–>
<% if startpageprocessing() then response.end() %>
<form name=thisform method=post>

<html>
<head>
<meta name=vi60_dtcscriptingplatform content="client (ie 4.0 dhtml)">
<meta name=vi60_defaultclientscript content=vbscript>
<meta name="generator" content="microsoft visual studio 6.0">
</head>
<body>

<script id=clienteventhandlersvbs language=vbscript>
<!–

sub btnok_onclick()
    dim rtnvalue
    set rtnvalue = logon.execute.checkpasswd(thisform.txtuserid.value,thisform.txtpasswd.value)
    
    select case rtnvalue.return_value
        case 0
            密码正确,转其他程序
            blahlah
        case 1
            msgbox("登录号错误,请重新输入!")
            
            set highlight
            set highlight = thisform.txtuserid.createtextrange
                highlight.select
            set focus
            thisform.txtuserid.focus
        case 2
            msgbox("密码错误,请重新输入!")
            set highlight = thisform.txtpasswd.createtextrange
                highlight.select
            thisform.txtpasswd.focus
        case 3
            msgbox("该用户已在别的工作站登录,请重新输入!")
            set highlight = thisform.txtpasswd.createtextrange
                highlight.select
            thisform.txtpasswd.focus
    end select
end sub

sub txtuserid_onkeyup()
    如果是回车键或下箭头
    if window.event.keycode=13 or window.event.keycode=40 then
        set highlight = thisform.txtpasswd.createtextrange
            highlight.select
        thisform.txtpasswd.focus
    end if    
    
end sub

sub txtpasswd_onkeyup()
    if window.event.keycode=13 or window.event.keycode=40  then
        thisform.btnok.focus
    end if
    
    如果是上箭头
    if window.event.keycode=38 then
        set highlight = thisform.txtuserid.createtextrange
            highlight.select
        thisform.txtuserid.focus
    end if    
end sub

sub window_onload
    thisform.txtuserid.focus
end sub

–>
</script>
<p align=center>操作员登录号:
<input  id=txtuserid name=txtuserid maxlength=2 style="height: 21px; width: 142px">
<br>
操作员  密码:
<input id=txtpasswd name=txtpasswd maxlength=4 style="height: 21px; width: 142px" type=password>
<br>
</p>
<p align=center>
<input id=btnok name=btnok align=center type=button value="确认" style="color: darkslategray; font-size: larger; font-style: normal; font-weight: bold; height: 35px; width: 86px">
</p>

</body>
<% vi 6.0 scripting object model enabled %>
<% endpageprocessing() %>
</form>
</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在浏览器里实现类似VB Form的界面控制
分享到: 更多 (0)

相关推荐

  • 暂无文章