62,244
社区成员




window.onfocus = function(){
$(":input[id^='btnOpration']").each(function(){
$(this).click(function(){
var val = $(":input[id$='txtExpressions']").val();
switch($(this).val())
{
case "←":
$(":input[id$='txtExpressions']").val(val.length>0?val.substring(0,val.length-1):"");
break;
case "CE":
$(":input[id$='txtExpressions']").val("");
break;
case "等于":
$(":input[id$='txtExpressions']").val(val+"=");
break;
case "小于":
$(":input[id$='txtExpressions']").val(val+"<");
break;
case "大于":
$(":input[id$='txtExpressions']").val(val+">");
break;
default:
//alert($(this).val());
$(":input[id$='txtExpressions']").val(val+(isField($(this).val())?"["+$(this).val()+"]":$(this).val()));
break;
}
});
});
}
function isField(val)
{
var params = new Array("0","1","2","3","4","5","6","7","8","9","+","-","*","/",".","(",")");
params = params.join(",");
if(params.indexOf(val)>=0)
{
return false;
}
return true;
}
<table cellpadding="0" cellspacing="0" border="1" width="98%" class="tablesort" style="MARGIN-TOP:0px;MARGIN-BOTTOM:0px">
<tr>
<td width="75%" style="MARGIN-LEFT:10px">
<asp:TextBox ID="txtExpressions" Runat="server" TextMode="MultiLine" Width="100%" Rows="6"></asp:TextBox></td>
<td style="VERTICAL-ALIGN:top">
<table class="opration">
<tr>
<td><input type="button" id="btnOpration10" value="1"></td>
<td><input type="button" id="btnOpration11" value="2"></td>
<td><input type="button" id="btnOpration12" value="3"></td>
<td><input type="button" id="btnOpration13" value="+"></td>
<td><input type="button" id="btnOpration14" value="←"></td>
</tr>
<tr>
<td><input type="button" id="btnOpration20" value="4"></td>
<td><input type="button" id="btnOpration21" value="5"></td>
<td><input type="button" id="btnOpration22" value="6"></td>
<td><input type="button" id="btnOpration23" value="-"></td>
<td rowspan="4" class="maxButton"><input type="button" id="btnOpration24" value="CE" style="HEIGHT:100%"></td>
</tr>
<tr>
<td><input type="button" id="btnOpration30" value="7"></td>
<td><input type="button" id="btnOpration31" value="8"></td>
<td><input type="button" id="btnOpration32" value="9"></td>
<td><input type="button" id="btnOpration33" value="*"></td>
</tr>
<tr>
<td><input type="button" id="btnOpration40" value="0"></td>
<td><input type="button" id="btnOpration41" value="."></td>
<td><input type="button" id="btnOpration42" value="等于"></td>
<td><input type="button" id="btnOpration43" value="/"></td>
</tr>
<tr>
<td><input type="button" id="btnOpration50" value="小于"></td>
<td><input type="button" id="btnOpration51" value="大于"></td>
<td><input type="button" id="btnOpration52" value="("></td>
<td><input type="button" id="btnOpration53" value=")"></td>
</tr>
</table>
</td>
</tr>
</table>
INPUT { BORDER-BOTTOM: #eee 1px groove; BORDER-LEFT: #eee 1px groove; BACKGROUND-COLOR: #f0f8ff; COLOR: blue; BORDER-TOP: #eee 1px groove; BORDER-RIGHT: #eee 1px groove }
.opration TD { WIDTH: 50px }
.opration INPUT { WIDTH: 100%; HEIGHT: 20px }
.rewidth TD { WIDTH: 150px }
.rewidth INPUT { WIDTH: 100%; HEIGHT: 20px }
.maxButton { HEIGHT: 100% }