HELP! Adding two numbers from input boxes, to a third output.
Currently it adds them without converting the input to integers. So. Ill just give you what I have. Help is very much appreciated.
:
<html>
<head>
<title>
COMSC 100 Assignment 6 by Tom Gonser 1401658
</title>
<script type="text/javascript">
// copy/paste the following three lines after the script tag in EVERY program
function getInputAsText(_id){return document.getElementById(_id).value}
function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)}
function setOutput(_id, _value){document.getElementById(_id).value = _value}
function calculate()
{
var firstNum, lastNum, fullNum
firstNum = getInputAsNumber("firstNumBox")
lastNum = getInputAsNumber("lastNumBox")
fullNum = firstNum + lastNum
setOutput("fullNumBox", fullNum)
}
</script>
</head>
<body>
Instructions:<br />
Type two numbers, and click computate. <br />
Something will happen.<br />
<br />
Input Values:<br />
Numbah Won <input id="firstNumBox" type="number" /><br />
Numbah Too <input id="lastNumBox" type="number" /><br />
<input type="submit" value="Computate" onclick="calculate()" />
<br />
Output value:<br />
Here ya go: <input id="fullNumBox" type="number" />
</body>
</html>
Hey you might not be glad cause i have no answers but questions how to make my code work... on same subject. HOpe you dont mind
Or if you find resolution let me know:
script>
function zbroji(broj1,broj2)
{
var c = broj1 + broj2;
document.write("<br>Zbroj te 2 vrijednosti je:"+c);
var a =document.getElementById('broj1').value;
var b =document.getElementById('broj2').value;
var a =parseInt(a);
var b =parseInt(b);
}
function pomnozi(broj1,broj2)
{
var d = broj1 + broj2;
document.write("<br>Mnozenjem ta dva broja dobijemo:"+d);
var a =document.getElementById('broj1').value;
var b =document.getElementById('broj2').value;
var a =parseInt(a);
var b =parseInt(b);
}
function ispis()
{
document.getElementById('ispis').innerHTML("zbroji(a,b)","pomnozi(a,b)")
}
Bookmarks