javascript - Show answer elsewhere -
i'm new javascript , i've searched several topics, couldn't find desired answer. using google sites making (financial) calculations, , started of using simple template found on website.
<script> function calcul(){ var x = parsefloat(document.getelementbyid("value1").value); var y = parsefloat(document.getelementbyid("value2").value); document.getelementbyid("answer").innerhtml=x+y; } </script> <form action="" id="nothing"> <input type="text" id="value1"> <input type="text" id="value2"> <input type="button" value="calculate" id="but" onclick="calcul()" /> </form> <p id="answer"></p>
i understand piece of scripting, want show answer elsewhere. example, instead of clicking on calculate , show answer on next paragraph, want this:
the answer is: <p id="answer"></p>
.
so on same line, 'the answer is' showing , answer/number showing after clicking on calculate.
can me out?
convert <p id="answer"></p>
<span id="answer"></span>
, add "the answer is" before in html code.
Comments
Post a Comment