<script type="text/javascript">
//第一题
var sum = 0;
function jsq(){
var a = prompt("输入第一个数");
var b = prompt("输入符号");
var c = prompt("输入第二个数");
if(b == "+"){
sum=(+a + +c);
return sum;
}
if(b == "-"){
sum=(+a - +c);
return sum;
}
if(b == "*"){
sum=(+a * +c);
return sum;
}
if(b == "/"){
sum=(+a / +c);
return sum;
}
}
//第二题
function qx(){
var c = document.getElementById("f");
var d = document.getElementsByTagName("input");
for(var i = 0; i < d.length; i++){
d[i].checked=c.checked;
}
}
function xzk(){
var c = document.getElementById("f");
var d = document.getElementById("b2");
var e = document.getElementById("a2");
if(d.checked==true && e.checked==true){
c.checked=true;
}else{
c.checked=false;
}
}
</script>
<body>
<button onClick="alert(jsq())">计算器</button>
<table border="1" cellpadding="20px" cellspacing="0" height="20px" width="300px;">
<tr>
<th><input id="f" type="checkbox" onClick="qx()"></th>
<th>用户名</th>
<th>姓名</th>
</tr>
<tr>
<td style="text-align:center"><input id="b2" type="checkbox" onClick="xzk()"></td>
<td style="text-align:center">admin</td>
<td style="text-align:center">admin</td>
</tr>
<tr>
<td style="text-align:center" id="a1"><input id="a2" type="checkbox" onClick="xzk()"></td>
<td style="text-align:center">admin</td>
<td style="text-align:center">admin</td>
</tr>
</table>
</body>