web123456

Addition, subtraction, multiplication and division using JavaScript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/"><html xmlns="http:///1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Realization of addition, subtraction, multiplication and division</title><script type="text/javascript">    function operation(){     //first number     var oneNumber =  parseInt(document.getElementById("one").value);  alert(oneNumber);    //Second number  var twoNumber =  parseInt(document.getElementById("two").value);  alert(twoNumber);    // Operators  var calculate = document.getElementById("select").value;  alert(calculate);    //Calculated results  var result = parseInt(document.getElementById("select").value);    /** *Calculated symbol judgment */  switch(calculate)  {      case'+':result = oneNumber + twoNumber;        break;      case'-':result = oneNumber - twoNumber;        break;      case'*':result = oneNumber * twoNumber;        break;      case'/':result = oneNumber / twoNumber;       break;       default:alert("Error.");       break;  } }</script></head><body>   <input type="text" id="one" size="12" style="width:40px; "/>    <select id="select">    <option value="+">+</option>    <option value="-">-</option>    <option value="*">*</option>    <option value="/">/</option> </select>   <input type="text" id="two" size="12" style="width:40px; "/> =   <input type="button" id="three" value="?" style="border:none; background-color:#FFFFFF;" onclick="operation();"/></body></html>