根本不需要传递aa,直接yy();return false就行<script language="javascript">
function yy(){
a1=document.form1.x1.value;
a2=document.form1.x2.value;
a3=document.form1.x3.value;
aa=document.form1.xx.value;
b1=eval(a1);
b2=eval(a2);
b3=eval(a3);
if (aa=="+")
{document.form1.x3.value=(b1+b2)
}
else if (aa=="-")
{document.form1.x3.value=(b1-b2)
}
else if (aa=="*")
{document.form1.x3.value=(b1*b2)
}
else if (aa=="/")
{document.form1.x3.value=(b1/b2)
}}
</script><form name=form1><table>
<tr><td><input type="text" name="x1" size="3"></td> <td>
<select name="xx"><option value="+">加</option>
<option value="-">减</option>
<option value="*">乘</option>
<option value="/">除</option></select>
</td> <td><input type="text" name="x2" size="3"></td> <td>=</td>
<td><input type="text" name="x3" size="3"></td>
<td><input type="submit" value="确定"onclick="yy();return false">
<input type="reset" value="取消"></td></tr></table></form>
function yy(){
a1=document.form1.x1.value;
a2=document.form1.x2.value;
a3=document.form1.x3.value;
aa=document.form1.xx.value;
b1=eval(a1);
b2=eval(a2);
b3=eval(a3);
if (aa=="+")
{document.form1.x3.value=(b1+b2)
}
else if (aa=="-")
{document.form1.x3.value=(b1-b2)
}
else if (aa=="*")
{document.form1.x3.value=(b1*b2)
}
else if (aa=="/")
{document.form1.x3.value=(b1/b2)
}}
</script><form name=form1><table>
<tr><td><input type="text" name="x1" size="3"></td> <td>
<select name="xx"><option value="+">加</option>
<option value="-">减</option>
<option value="*">乘</option>
<option value="/">除</option></select>
</td> <td><input type="text" name="x2" size="3"></td> <td>=</td>
<td><input type="text" name="x3" size="3"></td>
<td><input type="submit" value="确定"onclick="yy();return false">
<input type="reset" value="取消"></td></tr></table></form>
解决方案 »
- js实现无边窗口
- 【extjs】Ext.data.HttpProxy的问题,关于grid加载acion返回数据(struts2)
- 动态生成div将div设置为inline怎么没有效果?
- 怎么实现这种弹出效果
- 如何用Javascript将字符串转换成GB2312和UTF-8编码
- 用JS 实现的Ordered Binary Tree 的节点删除问题
- 关于得到option.label的值的问题!
- 请问怎样判断页面FORM已经提交,<form>里面没有 <INPUT TYPE='SUBMIT'>,
- 两 个框架的信息互传的问题。。在线等
- 多HTML页面引用同一个JS文件传递参数的问题
- 谁给解密一下这段代码,谢了
- JavaScript生成树的问题!!!!!!!!!!!!
function yy(){
a1=document.form1.x1.value;
a2=document.form1.x2.value;
a3=document.form1.x3.value;
aa=document.form1.xx.value;
b1=eval(a1);
b2=eval(a2);
b3=eval(a3);
if (aa=="+")
{document.form1.x3.value=(b1+b2)
}
else if (aa=="-")
{document.form1.x3.value=(b1-b2)
}
else if (aa=="*")
{document.form1.x3.value=(b1*b2)
}
else if (aa=="/")
{document.form1.x3.value=(b1/b2)
}}
</script><form name=form1><table>
<tr><td><input type="text" name="x1" size="3"></td> <td>
<select name="xx"><option value="+">加</option>
<option value="-">减</option>
<option value="*">乘</option>
<option value="/">除</option></select>
</td> <td><input type="text" name="x2" size="3"></td> <td>=</td>
<td><input type="text" name="x3" size="3"></td>
<td><input type="button" value="确定"onclick="yy()">
<input type="reset" value="取消"></td></tr></table></form>如上。
有俩个问题:
1)函数你没必要传入参数aa吧,也没有用
2)你确定按纽设置成submit,那即便你对了也看不到效果。
我建议大家写代码的时候给html控件搞个id
然后document.getElementById来获得
要不你在ie下正常
但是脱离了ie可能理都不理