首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

薪资表达式 字符串

2013-11-09 
工资表达式 字符串脚本:?var tempvalue //文本框显示var temp_key var all_str //用于验证四

工资表达式 字符串

脚本:

?

var tempvalue=""; //文本框显示
var temp_key = "";
var all_str=""; //用于验证四则运算合法 将所有代码转化成数字
var key_array = new Array();
var value_array = new Array();
var row=0; //数组标记 增加时加1,撤销时减1
//选择计算器
function setFormula(num){
?key_array.push(num);
?value_array.push(num);
?if(temp_value == ""){
??temp_value = value_array[row];
?}else{
??temp_value += value_array[row];
?}
?if(temp_key == ""){
??temp_key = key_array[row];
?}else{
??temp_key += key_array[row];
?}
?document.getElementById("accountDetailVO.formulaText").value = temp_value; //中文显示
?document.getElementById("accountDetailVO.formula").value = temp_key; //保存到数据库
?row++;
}
//选择工资项
function setFormulaItem(num){
?var items = document.getElementById("accountDetailVO.item");
?var itemName = "";
?var item = "";
?for(var i = 0; i < items.length; i++){
??if(items[i].selected){
??itemName = document.all.item.options[i].text;
??item = document.all.item.options[i].value;
??}
?}
?key_array.push(item);
?value_array.push(itemName);
?if(temp_value == ""){
??temp_value = value_array[row];
?}else{
??temp_value += value_array[row];
?}
?if(temp_key == ""){
??temp_key = key_array[row];
?}else{
??temp_key += key_array[row];
?}
?document.getElementById("accountDetailVO.formulaText").value = temp_value; //中文显示
?document.getElementById("accountDetailVO.formula").value = temp_key; //保存到数据库
?row++;
}
//撤销
function? clk_cancel(){
?if(row != 0){ //撤销时从数组中删除数据
?var end_key = key_array.pop();
?var end_value = value_array.pop();
?temp_key = temp_key.substring(0,temp_key.lastIndexOf(end_key));
?temp_value = temp_value.substring(0,temp_value.lastIndexOf(end_value));
?document.getElementById("accountDetailVO.formula").value = temp_key; //保存到数据库
?document.getElementById("accountDetailVO.formulaText").value = temp_value; //显示
??row--;
?}
}
function clk_delete(){
?document.getElementById("accountDetailVO.formula").value = "";
?document.getElementById("accountDetailVO.formulaText").value = "";
?temp_value = "";
?temp_key = "";
}
function clk_save(){
?var parent_window = parent.dialogArguments;
?var formula = parent_window.document.getElementById("accountDetailVO.formula");
?var formulaText = parent_window.document.getElementById("accountDetailVO.formulaText");
?var str=temp_key;
?str = str.replace(/[ ]/g,"");
?if(str == ""){
??alert("表达式为空,请重新编辑");
??return false;
?}
?if(/^(\(?[+-]?\(?\w+\.?\w*\)?[+-/\*]\(?[+-]?\(?\w+\.?\w*\)?)+$/.test(str)){
?}else{
??alert("表达式格式不正确,请修改");
??return false;
?}
?if(formula != null){
?formula.value = temp_key;
?}
?if(formulaText != null){
?formulaText.value = temp_value;
?}
?window.close();
}
function clk_close(){
?window.close();
}
function editForlula(){
?var formula = document.getElementById("accountDetailVO.formula");
?var formulaText = document.getElementById("accountDetailVO.formulaText");
?temp_key = formula.value;
?temp_value = formulaText.value;
}

?

-----------------------------页面-----------------------

?

<body onload="editForlula()">
<form name="accountDetailForm" method="post" action="">
<html:hidden name="accountDetailForm" property="accountDetailVO.formula"/>
<table width="99%" border="0" cellspacing="1" cellpadding="0"
?align="center">
?<tr type="button"
???value="确 定" onclick="javascript:clk_save();">?
???
???<input name="fh" type="button"
???value="清 除" onclick="javascript:clk_delete();">
???<input name="fh" type="button"
???value="撤 销" onclick="javascript:clk_cancel();">
???<input name="fh" type="button"
???value="关 闭" onclick="javascript:clk_close();">?
???</td>
?</tr>
</table>

<TABLE width="30%" border=2 width=50 height=60 cellpadding=1
?cellspacing=5 align="center">
??<tr>
???<td height="172" colspan="5"><html:textarea name="accountDetailForm"
????property="accountDetailVO.formulaText" rows="10" cols="60"
????styleId="isLongerTah100:公式" readonly="true" /></td>
???<td></td>
??</tr>
??<tr>
???<td? colspan="5">
???工资项名称
???</td>
??</tr>
??<tr>
???<td width="250" rowspan="6"><bean:define
????id="itemList" name="accountDetailForm"
????property="itemList" /> <html:select name="accountDetailForm"
????property="accountDetailVO.item" multiple="true" size="10"
????styleId="item" style="width:200px" ondblclick="setFormulaItem(this.value)" >
????<html:options collection="itemList" property="key"
?????labelProperty="value" />
???</html:select>
???</td>
????<TD colspan="2" align="center" ><input name="btnClear" type="Button"
????value="???? (???? " onclick="setFormula('(')"></TD>
???<TD colspan="2" align="center"><input name="btnClearEntry" type="Button"
????value="???? )??? " onclick="setFormula(')')"></TD>
???</tr>
??<TR>
???<TD ><input name="btnSeven" type="Button" value="? 7? "
????onclick="setFormula('7')"></TD>
???<TD><input name="btnEight" type="Button" value="? 8? "
????onclick="setFormula('8')"></TD>
???<TD><input name="btnNine" type="Button" value="? 9? "
????onclick="setFormula('9')"></TD>
???<TD><input name="btnNeg" type="Button" value="? +? "
????onclick="setFormula('+')"></TD>
??</TR>
??<TR>
???<TD ><input name="btnFour" type="Button" value="? 4? "
????onclick="setFormula('4')"></TD>
???<TD><input name="btnFive" type="Button" value="? 5? "
????onclick="setFormula('5')"></TD>
???<TD><input name="btnSix" type="Button" value="? 6? "
????onclick="setFormula('6')"></TD>
???<TD align=middle><input name="btnPlus" type="Button"
????value="? -? " onclick="setFormula('-')"></TD>
??</TR>
??<TR>
???<TD ><input name="btnOne" type="Button" value="? 1? "
????onclick="setFormula('1')"></TD>
???<TD><input name="btnTwo" type="Button" value="? 2? "
????onclick="setFormula('2')"></TD>
???<TD><input name="btnThree" type="Button" value="? 3? "
????onclick="setFormula('3')"></TD>
???<TD align=middle><input name="btnMultiply" type="Button"
????value="? *? " onclick="setFormula('*')"></TD>
??</TR>
??<TR>
???<TD colspan="2"><input name="btnZero" type="Button" value="???? 0???? "
????onclick="setFormula('0')"></TD>
???<TD><input name="btnDecimal" type="Button" value="? .? "
????onclick="setFormula('.')"></TD>
???<TD><input name="btnDecimal" type="Button" value="? /? "
????onclick="setFormula('/')"></TD>
??</TR>
??
</TABLE>
</FORM>
</body>

热点排行