• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

how to display salary calculator result in plain text, rather than in a popup alert window?

Hi. I am trying to edit a simple salary calculator javascript. The current script, below, does a math calculation, then pops up the result in an alert window.

Is there a way to display the result in simple text in the web page, rather than in an alert window?

Thank you for any advice.

Eric
<script language="JavaScript" type="text/javascript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function  doMath() {
var one = eval(document.theForm.elements[0].value)
var two = eval(document.theForm.elements[1].value)  
var prod = one  *   two
alert("Equivalent annual salary " +  "is " +  "$"  +  prod  +  ".")
}
// End -->
</script>
<form id="theForm" name="theForm">
    <p>Enter hourly wage <input size="10" type="text">
    <input value="2080" type="hidden"></p>
    <p><input onclick="doMath()" name="Calculate" value="Calculate" type="button"></p>
</form>

Open in new window

0
Eric Bourland
Asked:
Eric Bourland
  • 2
  • 2
1 Solution
 
COBOLdinosaurCommented:
Just add a div below the form:
<div id="result"></div>

Then script it this way:
function  doMath() {
var one = eval(document.theForm.elements[0].value)
var two = eval(document.theForm.elements[1].value)  
var prod = one  *   two
str ="Equivalent annual salary " +  "is " +  "$"  +  prod  +  ".";
document.getElementById('result').innerHTML=str;
}

Open in new window

0
 
Eric BourlandAuthor Commented:
I'll try this and get back to you. Thank you!
0
 
Eric BourlandAuthor Commented:
Worked like a charm. Thank you!

Eric
0
 
COBOLdinosaurCommented:
Glad I could help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now