[nfbcs] More help with javascript calculater
Taylor Arndt
taylorarndt99 at gmail.com
Fri Nov 25 02:29:49 UTC 2016
Hi,
So i got some of my calculater
--
Taylor
to work, but it seems like subtraction is the only thing it wants to
do now, and i want to implament all 4 functions
Here is the code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Accessible calculator</title>
<script>
function function_calculate(){
}
function function_add()
{
var first_number=parseFloat(document.getElementById('Text1').value);
var
second_number=parseFloat(document.getElementById('Text2').value);
var myResult=(first_number+second_number);
document.getElementById('txtresult').innerHTML = myResult;
}
function function_subtract()
{
var first_number=parseFloat(document.getElementById('Text1').value);
var
second_number=parseFloat(document.getElementById('Text2').value);
var myResult=(first_number-second_number);
document.getElementById('txtresult').innerHTML = myResult;
}
</script>
</head>
<body>
<p>
<br/>
<label for"first number">Enter the first
number: </label>
<input type="text" title="Enter first number:"
label="first number" name="first number" id="Text1" /><br/>
<label for"operation">Choose operation: </label>
<select>
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Divide</option>
</select>
<br/> <label for"2nd number">Enter the second number: </label>
<input type="text" title="2nd number" id="Text2"/><br/>
<button type="button" title="calculate" name="calculate"
onclick=" function_calculate(); function_add(); function_subtract();
function_multiply(); function_divide(); "/>Calculate</button>
</p>
<p style="font-size: xx-large; font-weight:
bolder;">result: <span id="txtresult"></span></p>
</body>
</html>
Thanks for all the help, and i apreciat it
More information about the NFBCS
mailing list