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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:30:01+00:00 2026-05-25T18:30:01+00:00

Amount <script type=text/javascript> <!– function interestVal() { var x = document.Amounts.valOfCar.value; var y =

  • 0

Amount

    <script type="text/javascript">
        <!--
         function interestVal() 
            {
                var x = document.Amounts.valOfCar.value;
                var y = document.Amounts.interestofCar.value;
                var z = x+y;
                document.Amounts.carInterest.value=z;
            }
        -->
    </script>


</head>
<body background="bg.jpg">
        <p>Calculate the cost of your car</p> 
        <form name = Amounts> 
            <p>Value of a car <input type="text"  value="" name=valOfCar></p>
            <p>Interest @15% <input type="text" value="" name=interestofCar></p>
            <p>Value + Interest<input type="text" name=carInterest></p>
            <p><input type=submit value=Calculate onClick=interestVal()></p>
        </form>
</body>

  • 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-25T18:30:02+00:00Added an answer on May 25, 2026 at 6:30 pm

    Here you go. I was able to reproduce your problem by just copying your code and running it. This code will run. The principal change I made, which I believe was the source of the problem, was altering from an input of type submit to a button. As a submit, it was doing a postback, which caused the contents of the controls to disappear. Using a button avoids the postback.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <script type="text/javascript">
            <!--
         function interestVal() {
             var x = document.Amounts.valOfCar.value;
             var y = document.Amounts.interestofCar.value;
             var z = x * y;
             document.Amounts.carInterest.value = z;
         }
            -->
        </script>
    
    
    </head>
    <body background="bg.jpg">
            <p>Calculate the cost of your car</p> 
            <form name = "Amounts"> 
                <p>Value of a car <input type="text"   name="valOfCar" /></p>
                <p>Interest @15% <input type="text"  name="interestofCar" /></p>
                <p>Value + Interest<input type="text" name="carInterest" /></p>
                <p><button type="button" onclick="interestVal();" >Calculate</button></p>
            </form>
    </body>
    </html>
    

    Another potential problem is that by summing x and y, you get their concatenated result, which is probably not what you want. I have changed that to multiplying x times y.

    Finally, I have enclosed many of the attribute values in quotes and made the inputs self-closing by ending the with /> instead of >.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript function to calculate total amount : <script> function calculate(v) {
I have an HTML document with the following form: <form> <input type=text id=price> <input
I'm making a favicon.ico script, and I need to know the max amount of
I'm having a problem with my python script. It's printing massive amounts of data
Selecting a large amount of text that extends over many screens in an IDE
I'm working on a Pig script (my first) that loads a large text file.
Here is client Side code: jQuery(document).ready(function(){ jQuery(#list).jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Inv No','Date',
I have a column with a text data type , but its an xml
I am trying to write a jQuery Ajax function, to reduce the amount of
I am trying to write a jQuery Ajax function, to reduce the amount 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.