<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> calculator </title>
<Script language = "javascript" type = "text/javascript">
Var clearFlag = false;
Function getNum (num ){
// Alert (num );
Var objresult = document. getElementById ("result ");
If (clearFlag ){
Objresult. value = "";
ClearFlag = false;
}
// Alert (objresult );
Objresult. value + = num;
}
Function getResult (){
Var objresult = document. getElementById ("result ");
Objresult. value = objresult. value + "=" + eval (objresult. value );
ClearFlag = true;
}
</Script>
</Head>
<Body>
<Table width = "200" border = "1" cellpadding = "2">
<Tr>
<Td colspan = "4"> <input type = "text" name = "result" id = "result" size = "33"> </td>
</Tr>
<Tr>
<Td width = "56"> <input type = "button" value = "1" onclick = "getNum (1)"> </td>
<Td width = "56"> <input type = "button" value = "2" onclick = "getNum (2)"> </td>
<Td width = "51"> <input type = "button" value = "3" onclick = "getNum (3)"> </td>
<Td width = "58"> <input type = "button" value = "+" onclick = "getNum ('+')"> </td>
</Tr>
<Tr> www.2cto.com
<Td> <input type = "button" value = "4" onclick = "getNum (4)"> </td>
<Td> <input type = "button" value = "5" onclick = "getNum (5)"> </td>
<Td> <input type = "button" value = "6" onclick = "getNum (6)"> </td>
<Td> <input type = "button" value = "-" onclick = "getNum ('-')"> </td>
</Tr>
<Tr>
<Td> <input type = "button" value = "7" onclick = "getNum (7)"> </td>
<Td> <input type = "button" value = "8" onclick = "getNum (8)"> </td>
<Td> <input type = "button" value = "9" onclick = "getNum (9)"> </td>
<Td> <input type = "button" value = "*" onclick = "getNum ('*')"> </td>
</Tr>
<Tr>
<Td> <input type = "button" value = "0" onclick = "getNum (0)"> </td>
<Td> <input type = "button" value = "." onclick = "getNum ('.')"> </td>
<Td> <input type = "button" value = "=" onclick = "getResult ()"> </td>
<Td> <input type = "button" value = "/" onclick = "getNum ('/')"> </td>
</Tr>
</Table>
</Body>
</Html>
From the column of youngerhao