新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:在浏览器里实现类似VB Form的界面控制

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

新客网 XKER.COM 2003-07-11 来源: 收藏本文
在浏览器里很容易实现类似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>
收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐