Using JavaScript to write a simple calculator

2010-08-05  来源:本站原创  分类:Web  人气:162 

<html>
<head>
<title> Simple Calculator </ title>
<script>
function doCal () (
var value1 = parseInt (document.getElementById ("value1"). value);
var flag = document.getElementById ("value1"). value
var value1 = parseInt (document.getElementById ("value1"). value);
eval ("var s =" + value1 + flag + value2);
document.getElementById ("result"). innerHTML = "<font color='red'>" + s + "</ font>";
)
</ Script>
</ Head>
<body>
<h1> simple calculator <h1>
<hr>
<input type="text" name="value1">
<select name="flag">
<option value="+"> + </ option>
<option value="-"> - </ option>
<option value="*"> * </ option>
<option value="/"> / </ option>
</ Select>
<input type="text" name="value2">
<input type="button" value"=">
<span> </ span>
</ Body>
</ Html>

相关文章
  • Using JavaScript to write a simple calculator 2010-08-05

    <html> <head> <title> Simple Calculator </ title> <script> function doCal () ( var value1 = parseInt (document.getElementById ("value1"). value); var flag = document.getElementById ("value1"). value var va

  • JS prepared by the simple calculator 2009-06-22

    Use JavaScript to write simple calculator , Normal operations executive function correctly, but the test does not complete ,bug Should be, to welcome noted . <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.o

  • JS prepared the simple calculator 2010-03-15

    Use JavaScript to write simple calculator , Normal operations executive function correctly, but the test does not complete ,bug Should be, to welcome noted . <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.o

  • JavaScript implementation of the scientific calculator to support four operations and functions, using Postfix Notation algorithm 2011-05-14

    Actually update the blog since the last two years, that this time I am really very, very busy, and there is no new knowledge to learn? Busy is true, but learned a lot the past two years many things, but most of them in software engineering or other t

  • Using python to write a simple calculator 2010-06-11

    http://blog.csdn.net/qqyyhh/archive/2007/04/12/1562523.aspx Python complete with a simple calculator, able to count simple +,-,×,/ operations not support keyboard input, will gradually increase after some additional features, it becomes more powerful

  • Achieved with a simple factory pattern - Simple Calculator 2010-03-29

    uml There uml diagram can be seen that Client rely OprationFactory class, while the OprationFactory class is called, Opration interface, When we want to increase the calculator function, modify the client to increase the corresponding sub-classes and

  • Beginners - Objective c write simple calculator 2010-11-10

    This is my first little objective c program, still lack basic knowledge in all aspects, with the relatively unfamiliar, the process is a little BUG, but busy drying out in the sun. Interface Builder first made by a simple graphical calculator: Choose

  • JavaScript CSS and a simple event 2008-12-03

    <!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-

  • Simple Calculator Java program 2010-04-04

    The program mainly uses the Reverse Polish expression, using simple addition and subtraction, multiplication and division stack, including the use of parentheses. All procedures are as follows, can be directly run. Of course, is limited, I hope Danie

  • Javascript and Java language simple comparison 2010-04-24

    Java javascript Weak type static dynamic strongly typed class-based prototype based on classes functions constructors functions methods functions function plays a Class, constructors, methods, three roles

  • js function to do a simple calculator 2008-06-06

    Just do a good job, need to continue to improve the

  • android interface to create the most simple calculator 2010-12-03

    Look at the map: This exercise is mainly about TableLayout layout, attention to one of the android: stretchColumns = "0,1,2,3" property, which can control the width of each column the weight of similar weight, as here, four are "equal"

  • A simple calculator program 2010-12-05

    const char number = '8'; const char quit = 'q'; const char print = ';'; const string prompt = ">"; const string result = "="; const char name = 'a'; const char let = 'L'; const string declkey = "let"; // Define Word class

  • Simple basic JavaScript 2010-06-09

    A basic knowledge of JavaScript language, JavaScript scripting language features JavaScript is a scripting language for web browser scripting language. Scripting language has the following features: 1, the client implementation. Completely run on the

  • Complete a simple PHP calculator 2010-10-08

    <html> <head> <title>PHP Simple calculator </title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> </head> <?php $num1=true; $num2=true; $numa=true; $numb=true; $message="

  • JavaScript to determine browser type and version 2009-06-08

    This article from: http://www.mak-s.com/200919141752.html JavaScript to determine browser type and version . maks (line-height: 150%; padding: 10px;). maks p (margin-bottom: 10px; text-indent: 2em). maks. t1 (font-size: 20px; font-weight: bold;). mak

  • MVP For GWT series of data reproduced 12: a thorough understanding of GWT Part 2: JavaScript's overlay type 2009-03-10

    The source text from: https: / / txt.appspot.com/pt2club.blogspot.com/2010/02/gwt-part-2javascript-overlay-type.html A thorough understanding of GWT Part 2: JavaScript's overlay type Original: http://googlewebtoolkit.blogspot.com/2008/08/getting-to-r

  • MVP For GWT Series data reserved 12: thorough understanding of the GWT Part 2: JavaScript's overlay type 2010-03-08

    Source article from: https: / / txt.appspot.com/pt2club.blogspot.com/2010/02/gwt-part-2javascript-overlay-type.html Thorough understanding of the GWT Part 2: JavaScript's overlay type Original: http://googlewebtoolkit.blogspot.com/2008/08/getting-to-

  • Ruby Getting Started bis (Calculator) 2010-02-03

    Use irb to use as a simple calculator to understand Ruby simple calculations. 1: input number and the operator can; irb(main):001:0>3+4 =>7 2: Calculate the square with a number **, for example, we calculate the square of the following 3 irb(main):0

  • Refresh GridView using Ajax partial simple implementation of data binding 2010-03-11

    Many users have such needs, such as: Click the button to refresh the data in the GridView, not the page refresh. In fact, the use of javascript to achieve a simple Ajax can be directly achieved. Specific code as follows: <%@ Page Language="C#"