JS 光标应用

1、JS的光标应用

  光标进入:

οnfοcus="PlanelAlbe('');"//:(进入控件时设置控件为显示)

οnblur="PlanelAlbe('none');"//:(退出控件时设置控件为不显示)

 js代码为:

 function PlanelAlbe(IsAble) {
            Panel1.style.display = IsAble;
        }

 2、编辑框的值赋给另一编辑框

2.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
 window.onload = function(){
   var oA =document.getElementById('a');
   var oB =document.getElementById('b');
   var oC =document.getElementById('c');
   oC.value = oA.value.charAt(0)+oB.value;
  }
</script>
</head>

<body>
 <input type="text" id="a" value="mike tom" />
    <input type="text" id="b" value="Jackson" />
    <input type="text" id="c" />
</body>
</html>

2.2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function $(id){return document.getElementById(id);}
window.onload = function(){
 var a = $("a"), b = $("b"), c = $("c");
 a.onblur = b.onblur = function(){
  if(a.value=="dd"){
   c.value = a.value.charAt(0) + b.value;
  }
 }
}
</script>
</head>
<body>
<p><input type="text" id="a" /></p>
<p><input type="text" id="b" /></p>
<p><input type="text" id="c" /></p>
</body>
</html>

2.3

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
a:<input type="text" id="t1" />
b:<input type="text" id="t2" />
c:<input type="text" id="t3" />
</body>
<script type="text/javascript" >
function $(id){return document.getElementById(id)};
function keyPress(){
 $("t3").value = $("t1").value.charAt(0) + $("t2").value;
};
$("t1").onkeyup = keyPress;
$("t2").onkeyup = keyPress;
</script>
</html>

2.4

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
 window.onload = function(){
   var oA =document.getElementById('a');
   var oB =document.getElementById('b');
   var oC =document.getElementById('c');
   oA.οnfοcus=oB.οnfοcus= function(){
   oC.value = oA.value.charAt(0)+oB.value;
   }
  }
</script>
</head>
<body>
 <input type="text" id="a" value="mike tom" />
    <input type="text" id="b" value="Jackson" />
    <input type="text" id="c" />
</body>
</html>

2.5 LabText赋值:document.getElementById("Label1").innerHTML==document.form1.TextBox1.Text";

3、点击按钮,新建页面,并锁定当前页面。将值传递到新页面,新页面操作后,返回新值,将值赋给旧页面指定控件,并执行操作。

     旧页面,前台:


        function ShowSelectMOWindow(UserCode, DivisionCode) {
            var param = "MONumber=" + document.getElementById("txtCONumber").value + "&Lin=" + document.getElementById("txtLine").value + "&DivisionCode=" + DivisionCode + "&UserID=" + UserCode;//将传递的值
            var returned = window.showModalDialog("FindOrderWasteRec.aspx?" + param, "生产订单选择", "dialogHeight: 420px; dialogWidth: 650px; edge: Raised; center: Yes; help: No; resizable: No; status: No;");//打开新页面
                        if (returned != null) {
                            document.getElementById("txtRecordNumber").value = returned;//接收新页面返回的值
                            document.getElementById("btnRecordSel").click();//执行事件
                        }

旧页面后台:

 string s1 =“”;

  string s2 ="";

        ScriptManager.RegisterStartupScript(this, this.GetType(), "edit", "ShowSelectMOWindow('" + s1+ "','" + s2+ "');", true);//调用前台function

新页面前台:


    <%-- <meta http-equiv="Refresh" />--%>   

<base target="_self" />//必需存在的语句
    <script type="text/javascript">
        function ShowSelect(QCID) {
            window.returnValue = QCID;//要返回的值
            window.close();//关闭前台页面
        }
       
    </script>
新页面后台:

 ScriptManager.RegisterStartupScript(this, this.GetType(), "edit", "ShowSelect('" + QCID + "');", true);//调用前台function     

 4、TextBox控件设置得到焦点时是全选状态: <asp:TextBox ID="TextBox1" runat="server" onFocus="this.select()"></asp:TextBox>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值