两个TextBox分别输入10%、20%,然后1减去它们,结果自动显示在Label中。。。。。。
两个TextBox分别输入10%、20%,然后1减去它们,结果自动显示在Label中
各位帮我看一下,用什么方法,谢谢
[解决办法]
TextBox tb1 = new TextBox();
TextBox tb2 = new TextBox();
Label l1 = new Label();
tb2.Attributes.Add( "onblur ", "document.all[ 'l1 '].value = 1-document.all[ 'tb1 ']-document.all[ 'tb2 '] ");
[解决办法]
<script type= "text/javascript ">
function a()
{
var a=document.getElementById( 'TextBox1 ').value;
alert(a);
var b=document.getElementById( 'TextBox2 ').value;
alert(b);
var c=1-a-b;
alert(c);
document.getElementById( 'Label1 ').innerHTML=c;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server " Style= "z-index: 100; left: 105px; position: absolute;
top: 112px "> </asp:TextBox>
<asp:TextBox ID= "TextBox2 " runat= "server " Style= "z-index: 101; left: 104px; position: absolute;
top: 157px " onblur= "a() "> </asp:TextBox>
<asp:Label ID= "Label1 " runat= "server " Style= "z-index: 103; left: 107px; position: absolute;
top: 192px " Text= " " > </asp:Label>
</div>
</form>
</body>