回车按钮转化为tab按钮
if(event.keyCode==13) event.keyCode=9;
滚动条滚动
<button onclick="text1.scrollTop=text1.scrollHeight">Scroll</button><br>
<textarea id="text1" cols=50 rows=10>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
</textarea>
.取消文本框自动完成功能
<input type="text" autocomplete="off">
让下拉框自动下拉
<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
弹出鼠标所在处的链结地址
<body onmouseover="if (event.srcElement.tagName=='A')alert(event.srcElement.href)"><a
href=".com/viewthread.php?tid=13589" >dddd</a><input>//
使鼠标滚轮失效
function document.onmousewheel()
{
return false;
}//
取得鼠标所在处的对象
var obj = document.elementFromPoint(event.x,event.y);//
获得相邻前者对象
<INPUT TYPE="text" NAME="gg"><INPUT TYPE="text" NAME="bb"
onclick="this.previousSibling.value='guoguo'">//
设置透明效果
document.form.xxx.filters.alpha.opacity=0~100//
if(event.keyCode==13) event.keyCode=9;
滚动条滚动
<button onclick="text1.scrollTop=text1.scrollHeight">Scroll</button><br>
<textarea id="text1" cols=50 rows=10>
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
</textarea>
.取消文本框自动完成功能
<input type="text" autocomplete="off">
让下拉框自动下拉
<select onmouseover="javascript:this.size=this.length" onmouseout="javascript:this.size=1">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
弹出鼠标所在处的链结地址
<body onmouseover="if (event.srcElement.tagName=='A')alert(event.srcElement.href)"><a
href=".com/viewthread.php?tid=13589" >dddd</a><input>//
使鼠标滚轮失效
function document.onmousewheel()
{
return false;
}//
取得鼠标所在处的对象
var obj = document.elementFromPoint(event.x,event.y);//
获得相邻前者对象
<INPUT TYPE="text" NAME="gg"><INPUT TYPE="text" NAME="bb"
onclick="this.previousSibling.value='guoguo'">//
设置透明效果
document.form.xxx.filters.alpha.opacity=0~100//
2007-07-31 09:19
/***************************************************/
* [来源 : [http://hi.baidu.com/9uflash ]
* [作者 : [烧开水的鱼 ]
* [说明 : 将如下代码放入第一帧,请自行添加所需元件]
/**************************************************/
var myContextMenu:ContextMenu = new ContextMenu();
//声明菜单新项
var item:ContextMenuItem = new ContextMenuItem("Hello World");
//添加到菜单显示项目数组
myContextMenu.customItems.push (item);
this.contextMenu = myContextMenu;//点击按钮引发该事件
item.addEventListener (ContextMenuEvent.MENU_ITEM_SELECT ,mouseRelease);
function mouseRelease (event:ContextMenuEvent)
{
var txtField:TextField=new TextField();
txtField.text="Hello World";
addChild (txtField);
}
<script>
function $(Id){return document.getElementById(Id);}
function Op(btn)
{
if(btn.value=="隐藏"){$("divGV").style.display="none";btn.value="显示";}
else{$("divGV").style.display="block";btn.value="隐藏";}
}
</script>
<input type="button" onclick="Op(this)" value="隐藏"/>
<div id="divGV">
学校简介
</div>
reapeater to be multyplied through javascript
Handle the ItemDataBound event of the Repeater
and hook the client-side code for the math.
void Repeater1_ItemDataBound (object sender, RepeaterItemEventArgs e)
{if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox txtUnitPrice = (TextBox)e.Item.FindControl ("TextBoxUnitPrice");
TextBox txtUnit = (TextBox)e.Item.FindControl ("TextBoxUnit");
TextBox txtTotal = (TextBox)e.Item.FindControl ("TextBoxAmount");
txtUnitPrice.Attributes.Add ("onblur", "calcTotal(" + txtUnitPrice.ClientID + ",
" + txtUnit.ClientID + ", " + txtTotal.ClientID + ");");
txtUnit.Attributes.Add ("onblur", "calcTotal(" + txtUnitPrice.ClientID + ", " + txtUnit.ClientID + ", " + txtTotal.ClientID + ");");
}
}
And have this JS on the .aspx:
<script language="javascript" type="text/javascript">
function calcTotal (objUnit, objUnitPrice, objTotal)
{objTotal.value = objUnit.value * objUnitPrice.value; }
</script>
want all the TestBoxAmount to be further added to as Grand Total in a text box
which is in footer of the repeater
Append this
ifblock to your existing ItemDataBound event handler:if (e.Item.ItemType == ListItemType.Footer)
{ TextBox txtTotalAmt = (TextBox)(e.Item.FindControl ("TextBoxTotalAmount")); ClientScript.RegisterClientScriptBlock (this.GetType(), "txtBoxID", "var txtTotalAmountId = '" + txtTotalAmt.ClientID + "'", true);}
And this JS to the .aspx code
<script language="javascript">function calcGrandTotal()
{ var txtObjs =document.getElementsByTagName("input");
var totalAmt = 0;
for (var i=0; i< txtObjs.length; i++)
{
if (txtObjs[i].type == "text" && txtObjs[i].id.indexOf("TextBoxAmount") >= 0)
{totalAmt += isNaN(txtObjs[i].value)?0:txtObjs[i].value;}
}
document.getElementById("txtTotalAmountId").value = totalAmt;
}
</script>
private void Page_Load(object sender, System.EventArgs e)
{
string javaScript =
"<script type='text/javascript'>\n"
"<!--\n" +
"window.document.body.onload = function ()\n" +
"{\n" +
" alert('window.document.body.onload fired');\n" +
"}\n" +
"// -->\n" +
"</script>\n";
ClientScript.RegisterStartupScript(GetType(Page), "BodyOnloadScript", javaScript, false);}
{
var textbox5 = document.getElementById('<%= txt5.ClientID %>');
if(textbox5.value.length == 0)
textbox5.value = "0.00";
}
2)function mymethod2(sender)
{
if(sender.value.length == 0)
sender.value = "0.00";
}
up:<asp:TextBox runat='server' ID='txt5' onblur='mymethod();' /><asp:TextBox runat='server' ID='txt6' onblur='mymethod2(this);' />
3)<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server" onblur="textBoxOnBlur(this);"></asp:TextBox>
</form><script type="text/JavaScript">
<!--
function textBoxOnBlur(elementRef)
{
if ( elementRef.value.length <= 0 )
elementRef.value = '0.0';
}
// -->
</script>Here I attached the event handler in the HTML up, but it is really better to attach it in the CodeBehind file like this:private void Page_Load(object sender, System.EventArgs e)
{
TextBox1.Attributes.Add("onblur", "textBoxOnBlur(this);");
}