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

  • SEARCH
  • Home
  • 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 6938551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:30:28+00:00 2026-05-27T12:30:28+00:00

Im having trouble with this javascript. here is a n example window.onload = initPage;

  • 0

Im having trouble with this javascript. here is a n example

 window.onload = initPage;

var euro;
var convert;

function initPage()
{
    document.getElementById("convertButton").onclick = calcAnswer();
    document.getElementById("conversionType").onchange = calcAnswer();
}

function calcAnswer()
{
    //alert(document.getElementById("conversionType").value);

    var value1 = document.getElementById("amount").value;
    var conversionType = document.getElementById("conversionType").value;
    //alert(conversionType);

    if(var value = document.getElementById("conversionType").value=="polish");
        document.getElementById("answer").value=(value1-32)/9*5;
    else
        document.getElementById("answer").value=value1*9/5+32;
}

here is the html

  <h1>Currency Converter</h1>


  <form name="convert">

Choose which currency you would like to convert to the Euro:
<select id="conversionType">
    <option value="polish">Polish Zloty</option>
    <option value="ukraine">Ukraine Hryvnia</option>
</select>
</br>
</br>

<hr>
      Amount:<input id="amount" type="text" />
<input id="convertButton" type="button" value="Convert->"/>
      To:
<input id="answer" type="text" name="answer" readonly="readonly"/>


</form>

im using an old temperature converter and havent changed that part part but even that part is not working.

  • 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-05-27T12:30:28+00:00Added an answer on May 27, 2026 at 12:30 pm

    For starters, these two lines are wrong:

    document.getElementById("convertButton").onclick = calcAnswer();
    document.getElementById("conversionType").onchange = calcAnswer();
    

    Change them to:

    document.getElementById("convertButton").onclick = calcAnswer;
    document.getElementById("conversionType").onchange = calcAnswer;
    

    You want to assign a function reference to onclick and onchange, not actually call the function and assign the return value.

    Then, fix the if statement in calcAnswer like this:

    function calcAnswer()
    {
        var amount = document.getElementById("amount").value;
        var conversionType = document.getElementById("conversionType").value;
        var answerElement = document.getElementById("answer");
        //alert(conversionType);
    
        if(conversionType == "polish") {
            answerElement.value = (amount-32)/9*5;
        } else {
            answerElement.value = amount*9/5+32;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having trouble getting success from this... <!-- Ajax --> <script type=text/javascript> $('a.clickup').click(function (event) {
I am new to OOP Javascript and am having trouble with the this keyword
I am having trouble with the json.getJSON method. Here is my current code: var
I am having trouble with my javascript. It seems to be acting oddly. This
Having some trouble here with this. The setup: A select object with a choice
I'm having trouble with this code: NSRect itemFrame; id item; // code to assign
I'm having trouble understanding this question, and the explanation of the answer for an
I'm having trouble with this PHP script where I get the error Fatal error
I'm having trouble figuring this out. If I have a checkboxlist inside a usercontrol,
I am having trouble with this association. I need to get an array of

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.