Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7910711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:58:23+00:00 2026-06-03T12:58:23+00:00

I have searched the web for (what I am expecting to be) a basic

  • 0

I have searched the web for (what I am expecting to be) a basic answer to this question.

I have an HTML form I am putting together for a specific system. I have two text fields that a user will input two temperatures into. I want to have a third text field that onBlur, will generate the difference between these two temperatures. I have a script which I think is heading in the right direction, but does not work. Because of the system I will be using this for, I cannot have tags in the HTML.

My script:

    <script language="javascript" type="text/javascript">
    <!--
    function calculate_temp(TempIn, TempOut) {
    var TempIn = parseInt(document.getElementById('TempIn').value);
    var TempOut   = parseInt(document.getElementById('TempOut').value); 
    var Delta = TempIn - TempOut;
    document.getElementById('Delta').innerHTML = Delta
    }
    // -->
    </script>

My HTML:

    <body> 
    <div> 
    <p><label for="TempIn">TempIn: </label><input type="text" name="TempIn" id="TempIn" /></p>
    <p><label for="TempOut">TempOut: </label><input type="text" name="TempOut" id="TempOut" /></p>
    <p><label for="Delta">Delta: </label> <input type="text" name="Delta" id="Delta" onBlur="calculate_temp(this.form.TempIn.value, this.form.TempOut.value)"/></p>
    </div> 
    </body>

Can anyone explain what I am doing wrong here? Again, I want the user to input TempIn, hit tab, input TempOut, hit tab and then the Delta be calculated automatically.

Like I said, every resource I find online does it a slightly different way, but I can’t seem to get it working if I use any of the approaches.

Any help is greatly appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:58:25+00:00Added an answer on June 3, 2026 at 12:58 pm
    1. Remove the comments in your script: .
    2. All tags and attribute names must be lowercase in XHTML (optional). i.e:
      onblur.
    3. For your expected behavior, I recommend use the onfocus event,
      it makes more sense.
    4. You don’t need to pass nothing to the calculate_temp() function if
      you can access the elements through the script.
    5. Change the value of the Delta input with the value property.

    Result:

    <head>
    
    <title>Untitled 1</title>
    
        <script language="javascript" type="text/javascript">
            function calculate_temp(TempIn, TempOut) {
                var TempIn = parseInt(document.getElementById('TempIn').value);
                var TempOut   = parseInt(document.getElementById('TempOut').value); 
                var Delta = TempIn - TempOut;
                document.getElementById('Delta').value = Delta
            }   
        </script>
    
    </head>
    
    <body>
    
        <div> 
        <p><label for="TempIn">TempIn: </label><input type="text" name="TempIn" id="TempIn" /></p>
        <p><label for="TempOut">TempOut: </label><input type="text" name="TempOut" id="TempOut" /></p>
        <p><label for="Delta">Delta: </label> <input type="text" name="Delta" id="Delta" onfocus="calculate_temp()"/></p>
        </div> 
    
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows Forms, VB. I have searched the web for the correct answer to this
I have searched this web looking for an answer, but it seems that this
I have searched all over the web with no luck of making this project
i have searched the web relentlessly for this and have not found anything -
I have searched the web for the answer and saw that mostly variables are
I have searched the web for resolution of this error, but everything I have
I have searched the web for the answer and have found quite a few
I have searched the web for this but so far got nowhere. I have
I have this problem for a long time now, I have searched the web
I have searched the web for a way to do this, but perhaps I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.