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 8671685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:00:35+00:00 2026-06-12T19:00:35+00:00

I have a question on as why my code won’t execute correctly, I need

  • 0

I have a question on as why my code won’t execute correctly, I need to be as basic as possible when applying these commands. I hit the convert button and nothing, did I need a command for that too? It is for homework, I have been dabbling at it for hours.

EDIT***

  <html>
<head>

<script type="text/javascript">
<script>
function Convert()
onclick= document.getElementById('Convert')

    var years = document.getElementById("year").value;
    var days = document.getElementById("days").365.25 * years;
    var hours = document.getElementById("hours").(365.25 * 24) * years;
    var minutes = document.getElementById("minutes").(365.25 * 24 * 60) * years;
    var seconds = document.getElementById("seconds").(365.25 * 24 * 60 * 60) * years;

document.getElementById('days').value = days;
document.getElementById('hours').value = hours;
document.getElementById('minutes').value = minutes;
document.getElementById('seconds').value = seconds;



});
    </script>
  </head>
  <body>
    Years: <input type='text' id='years' /> 
    <button id='Convert'onclick= "Convert()" value= "Convert"/> Convert </button>

    Days: <input type='text' id='days' /> 
    Hours: <input type='text' id='hours' /> 
    Minutes: <input type='text' id='minutes' /> 
    Seconds: <input type='text' id='seconds' /> 
  </body>
 </html> 
  • 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-12T19:00:39+00:00Added an answer on June 12, 2026 at 7:00 pm

    A few things (hopefully they get you going again):

    1. You never call your function. Add an onClick handler to your button.
    2. You are prompt ing fixed strings instead of variables.
    3. You’ll have to extract the data from the input in your JavaScript. You could use document.getElementById() for that.

    Note, I could give you the answer, but homework and learning is all about figuring stuff out by yourself. Get going with my tips and see what you can come up with. Edit your question with what you got if you get stuck again.

    Okay, next round. What you’ll have to do in your Convert function:

    1. First, fetch the information from the form like this:

       var years = document.getElementById("year").value;
      
    2. Then, do you calculations:

       var days = 365 * years;
      
    3. Finally, write back the results:

      document.getElementById("days").value = days;
      

    Some extra tips:

    1. You are missing a space between id='Convert' and onclick
    2. Install a debugger like Firebug for Firefox.

    Good luck!

    Round three; here is the complete answer. Just try to understand what is going on. It is usually good to learn from working examples.

    Extra stuff I found:

    1. An extra <script> tag in your html
    2. The function definition is wrong, it should be function foo() { }

    —— complete answer follows —–

    <html>
    <head>
    
    <script type="text/javascript">
    
    // Declare a function called Convert()
    function Convert() {
        // Get the value of what the user entered in "years"
        var years = document.getElementById("years").value;
    
        // Calculate all the other values
        var days = years * 365.25;
        var hours = days * 24;
        var minutes = hours * 60;
        var seconds = minutes * 60;
    
        // Write the results in the input fields    
        document.getElementById('days').value = days;
        document.getElementById('hours').value = hours;
        document.getElementById('minutes').value = minutes;
        document.getElementById('seconds').value = seconds;
    }
    </script>
    </head>
      <body>
        Years: <input type='text' id='years' /> 
        <!-- define a button that will call Convert() when clicked on -->
        <button id='Convert' onclick= "Convert()" value="Convert">Convert</button>
    
        Days: <input type='text' id='days' /> 
        Hours: <input type='text' id='hours' /> 
        Minutes: <input type='text' id='minutes' /> 
        Seconds: <input type='text' id='seconds' /> 
      </body>
     </html> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question i.e how can i select a previous div CODE:- if($i >
I have a question about the following code in TCL/EXPECT: expect { timeout {
I have a question about the following C code: void my_function() { int i1;
I have a question regarding the following code snippet I came across in one
I have a question about the following code : #include <iostream> #include <ctime> int
I have a question about defining Foreign Key in EF Code First Fluent API.
I have a question about a programming problem from the book Cracking The Code
So I just have posted a question about this code (which was answered): $(document).ready(Main);
i have a question , i have this timer code in java that when
I have a question about how GC works in Java. Consider the following code:

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.