- 浏览: 108699 次
- 性别:
- 来自: 北京
文章分类
最新评论
脚本:
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"
class="ReportTable" align="center">
<tr class="ButtonTableContent">
<td align="right">
<input name="fh" class="Button2_mouseout"
onmouseover="this.className='Button1_mouseover'"
onmouseout="this.className='Button2_mouseout'"
onmousedown="this.className='Button1_mousedown'"
onmouseup="this.className='Button1_mouseup'" type="button"
value="确 定" onclick="javascript:clk_save();">
<input name="fh" class="Button2_mouseout"
onmouseover="this.className='Button1_mouseover'"
onmouseout="this.className='Button2_mouseout'"
onmousedown="this.className='Button1_mousedown'"
onmouseup="this.className='Button1_mouseup'" type="button"
value="清 除" onclick="javascript:clk_delete();">
<input name="fh" class="Button2_mouseout"
onmouseover="this.className='Button1_mouseover'"
onmouseout="this.className='Button2_mouseout'"
onmousedown="this.className='Button1_mousedown'"
onmouseup="this.className='Button1_mouseup'" type="button"
value="撤 销" onclick="javascript:clk_cancel();">
<input name="fh" class="Button2_mouseout"
onmouseover="this.className='Button1_mouseover'"
onmouseout="this.className='Button2_mouseout'"
onmousedown="this.className='Button1_mousedown'"
onmouseup="this.className='Button1_mouseup'" 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>
发表评论
-
存储过程
2015-01-26 14:46 0明将军南风北雪舞,厉鬼判官龙,方过一水寒,得拜将军府。 CnB ... -
js 页面跳转
2012-07-09 15:12 6981. Javascript 返回上一页 history.go( ... -
js 在iframe中的两个页面传值
2012-07-06 15:39 861所有的在同一目录下面: 第一个页面: <!DOCTY ... -
js打开新窗口设置窗口大小
2011-03-02 14:14 1536javascript:g_OpenWindow(url.jsp ... -
js多选框左移
2011-03-02 14:09 1220<!DOCTYPE HTML PUBLIC " ... -
js 跳出框架或 iframe
2011-03-02 13:50 976top.location.href='url' -
js 刷新父页面
2011-03-02 13:49 761parent.location.reload(); -
java 播放音频文件
2011-03-02 13:30 1643<html> <head> &l ... -
js计算表格列合计
2010-03-25 21:42 2752<script type="text/java ... -
js获取表格列的值
2010-03-24 17:02 3874//0行0列 var oTd = document.g ... -
js子窗口得到父窗口的值
2010-03-23 10:15 1208var parent_window = parent.dial ... -
将当前列表<select>中选中的值<option>移动到目标列表
2010-03-23 10:11 1569ajax公共文件 ajax.js /****** ... -
js动态增加 删除行
2010-03-23 10:03 1106添加页面: <!DOCTYPE HTML PUBLIC ... -
复选框 选择 全选
2010-03-09 16:03 941页面: <td align="right&q ... -
复选框移动脚本
2010-03-09 15:56 846页面显示 <td rowspan="4&qu ...
相关推荐
### Delphi 计算字符串表达式 在 Delphi 编程语言中,处理字符串表达式的计算是一项常见的任务,尤其是在需要动态解析数学表达式的情况下。本文将深入探讨如何编写一个简单的数值字符表达式计算函数,该函数能够...
字符串是不可变的数据类型,可以通过索引访问其字符,并且支持多种方法,如`Substring`用于提取子字符串,`Replace`用于替换特定字符或子串,以及`Split`用于分割字符串成字符串数组。在处理计算公式时,`Split`方法...
内插字符串表达式可以插入任何类型的数据,包括基本类型、对象实例甚至是复杂的表达式结果。下面是一个简单的示例: ```csharp var name = "小胡子"; var age = 26; var email = "xiaohuzi@xiaohuzi.com"; var ...
C# 6.0引入了一种新的字符串操作方式——字符串插值(String Interpolation),它为程序员提供了更直观、简洁的格式化字符串方法。在之前的版本中,我们通常使用`String.Format`或`StringBuilder`来构造包含变量的...
1. **字符串表达式解析**:在Delphi7中,我们经常需要将用户的输入,如字符串形式的数学公式,转换为可执行的计算。这通常涉及到字符串处理和表达式解析。例如,用户可能输入"2 + 3 * 4",程序需要识别出加法和乘法...
Oracle数据库系统中,字符串操作是数据库查询和管理中的基础且重要的一部分。在本文中,我们将深入探讨Oracle中的字符串处理函数和相关知识,这些知识对于数据库管理员和开发人员来说至关重要。 首先,DQL,即Data ...
7. **类型转换**:在计算过程中,不同类型的值可能需要进行转换,例如从字符串到数值类型。`Convert`类或`int.TryParse`等方法可以帮助完成这些转换。 8. **编译和运行时计算**:C#可以通过`Compile`方法将表达式树...
字符串格式化是将数据转换为字符串的过程,这在编程中非常常见,尤其是在构建输出消息或处理用户输入时。本文将详细介绍Python中字符串格式化的几种常用方法,并通过实例代码来演示它们的用法。 首先,Python中最...
2. **字符串处理**:用户输入的表达式通常以字符串形式接收。JS提供了丰富的字符串方法,如`split()`用于按分隔符拆分字符串,`trim()`去除两端空白,以及`replace()`替换特定字符等,这些都可能在解析用户输入时...
在给定的部分内容中,定义了一个JavaScript函数`functionIsURL(str_url)`,该函数利用正则表达式来验证传入的字符串是否为一个合法的URL。 ##### 正则表达式结构拆解: - **协议部分**:`^((https|http|ftp|rtsp|...
以下是一些关于Access表达式的知识点,主要涵盖基本操作、简单应用、日期函数、字符串函数、统计函数以及SQL子查询。 **基本操作(表)** 1. 使用`DateSerial`函数可以计算特定日期,例如`DateSerial(Year(Date())-...
`LENGTH()`返回字符串的长度,`TRIM()`去除字符串两端的空白字符,`LOWER()`和`UPPER()`用于大小写的转换,`REPLACE()`替换字符串中的特定子串,以及`REGEXP_LIKE()`用于正则表达式的匹配。 在实际应用中,熟练掌握...
例如,如果字符串包含双引号,可以使用反斜杠(`\`)作为转义字符,如`\"`。在任务2中,学生需要编写代码输出包含转义双引号的字符串"祝你生日快乐!"。 3. **自增自减运算符**: PHP中的自增`++`和自减`--`运算符...
// 正则表达式匹配字符串中的URL preg_match_all("/http:[\/]{2}[a-z]+[.]{1}[a-z\d\-]+[.]{1}[a-z\d]*[\/]*[A-Za-z\d]*[\/]*[A-Za-z\d]*/", $postInfo['answer2'], $array2); print_r($array2); ``` 这段代码中的...
正则表达式是一种强大的文本处理工具,能够帮助我们完成各种复杂的字符串搜索与替换功能。在本篇文章中,我们将详细介绍一些常用的正则表达式及其应用场景。 #### 二、具体知识点分析 ##### 1. 数字验证 - **整数...
本程序中用赋值语句给num和name两个成员赋值,name是一个字符串指针变量。用scanf函数动态地输入sex和score成员值,然后把boy1的所有成员的值整体赋予boy2。最后分别输出boy2 的各个成员值。本例表示了结构变量的...
5. Python字符串处理:`eval()`函数可以将字符串转换为可执行的Python表达式,但使用时需谨慎,因为可能会引入安全风险。 6. 逻辑表达式的等价性:理解逻辑表达式之间的等价关系,例如`x!=y>5`等价于`x!=y and y>5`...
**语法**: RPAD(字符串, 总长度, 填充字符)/LPAD(字符串, 总长度, 填充字符) **示例**: 对字符串'gao'进行左右两侧填充'*'至总长度为17。 ```sql SQL> SELECT LPAD(RPAD('gao', 10, '*'), 17, '*') FROM DUAL; ``` ...
3. **第7次-CSP201409_3字符串匹配.doc** - 又一个关于字符串处理的题目,可能需要掌握字符串的高级操作,比如正则表达式、动态规划方法在字符串匹配中的应用等。 4. **第2次-CSP201409-1相邻数对.doc** - 这可能是...