mercredi 11 mars 2015

JavaScript Calculator in my Quiz


Vote count:

0




This is the code I will use for my quiz. Can you please insert other buttons for trigonometric functions(e.g. sin,cos,tan)? And also what is wrong withthe code?





<script type="text/javascript">
function a(){
alert('Adds the two numbers.');}
function b(){
alert('Subtracts the second number from the first number.');}
function c(){
alert('Multiplies the two numbers.');}
function d(){
alert('Divides the second number from the first number.');}
function add(){
var ans = form.none.value + form.notwo.value;
alert(form.none.value + '+' +form.notwo.value + '=' + ans);
}
function subtract(){
var ans = form.notwo.value - form.none.value;
alert(form.notwo.value + '-' form.none.value+ '=' + ans);
}
function times(){
var ans = form.none.value * form.notwo.value;
alert(form.none.value + '*' +form.notwo.value + '=' + ans);
}
function over(){
var ans = form.notwo.value / form.none.value;
alert(form.notwo.value + '/' form.none.value+ '=' + ans);
}
</script>



<style>
h1{font-color: red;}
body{ background-color: aquamarine;}
</style>



<!DOCTYPE html>
<html>
<head><title> JAVAcalc </title></head>
<body>

<h1> The Java Calculator </h1>
<form name="me">
Enter all of the textfields required and click the button to use an operation.<br>
First number: <input type = "textbox" name="none" id="none"value="0">
Second number: <input type = "textbox" name="notwo" id="none" value="0"><br>
<input type = "button" name="none" value="Add!" onclick="add()" onmouseover="a()">
<input type = "button" name="none" value="Subtract!" onclick="subtract()" onmouseover="b()">
<input type = "button" name="none" value="Multiply!" onclick="times()" onmouseover="c()">
<input type = "button" name="none" value="Divide!" onclick="over()" onmouseover="d()">

</body>
</html>



Thanks in advance! Have a good day!



asked 39 secs ago







JavaScript Calculator in my Quiz

Aucun commentaire:

Enregistrer un commentaire