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>