计算器的问题,请教一下。 注意下类型问题就可以了parseInt() 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>一个简单的计算器</title><style type="text/css">.style1 {color: green}input.style_{background-color:#fff;border:0}body,td,th {font-size: 9pt; color: #000000;}body { background-color: lavender;}</style></head><script language="javascript1.2">function Validator(){ var aa =document.thistest.the1.value; var cc = document.thistest.the3.value; var count=0; if (aa=="") { alert ("您的第一个数没有输入!\n\n请填写完整。"); document.thistest.the1.select(); return false; } if (cc=="") { alert ("您的第二个数没有输入!\n\n请填写完整。"); document.thistest.the3.select(); return false; }var tt="";var radios = document.all.the2;for(var i=0; i<radios.length; i++){ if(radios[i].checked){ tt=radios[i].value; count += 1; document.thistest.the4.value=eval(aa+tt+cc);}}if(count==0){alert("您还没有选择运算符!\n\n请填写完整。");return false;}if(document.thistest.elements['the2'].length<0) { alert("您还没有选择运算符!\n\n请填写完整。"); return false; }if ((cc==0)&&(radios[3].checked)) { alert ("除数不能为零。"); document.thistest.the4.value=""; return false; } }</script><body><p><span class="style1">一个简单的计算器</span>:</p><p>当用户点击“=”按扭时能根据用户选择的操作符将结果计算出来:</p><p>要求:<ol> <li>能判断操作数完整输入后才计算</li> <li>除数不能为0</li></ol></p><table width="100%" border="0"><form name="thistest"> <tr> <td width="23%" height="38"> <input name="the1" type="text" size="20" class="style_"></td> <td width="6%"> <p> <input type="radio" name="the2" value="+"> + <br> <input type="radio" name="the2" value="-"> - <br> <input type="radio" name="the2" value="*"> * <br> <input type="radio" name="the2" value="/"> / <br> </td> <td width="18%"> <input name="the3" type="text" class="style_" id="the3" size="20"> </td> <td width="6%"> <input type="button" name="Submit" value=" = " class="style_" onclick="return Validator()"></td> <td width="47%"> <input name="the4" type="text" class="style_" id="the4" size="20"></td> </tr> </form></table></body></html> span 动态绑定事件 Jquery Validate.js 验证Select 如何改变当前窗口 resizable属性 Dreamweaver 源代码字体,为什么这么难看。 JS从表格copy数据到excel的问题 打开新层的效果。 请问这个效果怎么实现?例子 能动态取input值吗? 有关JQuery插入层层,请大佬指点. 我知道高手都在线 input type=button 如何让他象链接一样连到一个页面 有没有办法避免链接为“#”时的页面回置?? object中画线 100分求一段24小时只运行一段 ‘js引用代码‘ 一次的代码
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>一个简单的计算器</title>
<style type="text/css">
.style1 {color: green}
input.style_{background-color:#fff;border:0}
body,td,th {font-size: 9pt; color: #000000;}
body { background-color: lavender;}
</style>
</head>
<script language="javascript1.2">
function Validator()
{
var aa =document.thistest.the1.value;
var cc = document.thistest.the3.value;
var count=0;
if (aa=="")
{
alert ("您的第一个数没有输入!\n\n请填写完整。");
document.thistest.the1.select();
return false;
}
if (cc=="")
{
alert ("您的第二个数没有输入!\n\n请填写完整。");
document.thistest.the3.select();
return false;
}
var tt="";
var radios = document.all.the2;
for(var i=0; i<radios.length; i++)
{
if(radios[i].checked)
{
tt=radios[i].value;
count += 1;
document.thistest.the4.value=eval(aa+tt+cc);
}
}
if(count==0)
{
alert("您还没有选择运算符!\n\n请填写完整。");
return false;
}
if(document.thistest.elements['the2'].length<0)
{
alert("您还没有选择运算符!\n\n请填写完整。");
return false;
}if ((cc==0)&&(radios[3].checked))
{
alert ("除数不能为零。");
document.thistest.the4.value="";
return false;
}
}
</script>
<body>
<p><span class="style1">一个简单的计算器</span>:</p>
<p>当用户点击“=”按扭时能根据用户选择的操作符将结果计算出来:</p>
<p>要求:
<ol>
<li>能判断操作数完整输入后才计算</li>
<li>除数不能为0</li>
</ol></p>
<table width="100%" border="0">
<form name="thistest">
<tr>
<td width="23%" height="38">
<input name="the1" type="text" size="20" class="style_"></td>
<td width="6%">
<p>
<input type="radio" name="the2" value="+"> + <br>
<input type="radio" name="the2" value="-"> - <br>
<input type="radio" name="the2" value="*"> * <br>
<input type="radio" name="the2" value="/"> / <br>
</td>
<td width="18%">
<input name="the3" type="text" class="style_" id="the3" size="20"> </td>
<td width="6%">
<input type="button" name="Submit" value=" = " class="style_" onclick="return Validator()"></td>
<td width="47%">
<input name="the4" type="text" class="style_" id="the4" size="20"></td>
</tr>
</form></table></body></html>