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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:58:24+00:00 2026-06-12T06:58:24+00:00

I have the following javascript function: function updatePrintCost() { var qty = parseFloat(document.getElementById(‘qty’).value); var

  • 0

I have the following javascript function:

function updatePrintCost()
{
    var qty = parseFloat(document.getElementById('qty').value);
    var pp = parseFloat(document.getElementById('pp').value);

    var finalPrice = qty * pp;

    if (!isNaN(finalPrice))
        fp.value = "$" + finalPrice.toFixed(2);
    else
        fp.value = "Error";
}

it’s called by the following HTML code:

<table>
    <tr>
        <td style='border:none;'>Quantity:</td>
        <td style='border:none;'><input type='text' id='qty' name='quantity' onChange="updatePrintCost()" style='width:50px;' /></td>
        <td style='border:none;'>Print Price:</td>
        <td style='border:none;'><input type='text' name='printPrice' id='pp' onChange="updatePrintCost()" style='width:50px;' /></td>
        <td style='border:none;'> = </td>
        <td style='border:none;'><input type='finalPrice' id='fp' placeholder='0.00' style='width:75px;' /></td>
    </tr>
</table>

I put some alert tests in there, and the function IS being called, but fails out when it comes to setting the value of fp.

Can anybody see why this won’t work?

  • 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-12T06:58:25+00:00Added an answer on June 12, 2026 at 6:58 am

    Where is your declaration of fp? You need:

    var fp = document.getElementById('fp');
    

    Or:

    if (!isNaN(finalPrice)) 
           document.getElementById('fp').value = "$" + finalPrice.toFixed(2); 
    else 
           document.getElementById('fp').value = "Error"; 
    

    You also have a weird html input in type finalPrice rather than a regular type.

    See this if you want to know why it was working in Firefox. This is a cross browser solution. The way you were doing it works in only newer browsers.

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

Sidebar

Related Questions

I have the following javascript function hide(id) { var ele = document.getElementById(id); if ((ele.style.display
I have following code in JavaScript function checkEntries() { if(document.getElementById(username)== && document.getElementById(password).value==) { alert(Please
I have the following JavaScript code - function addOnClickEventHandler() { var userNameElement = document.getElementById(currentUser);
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==
I Have The Following JavaScript Function: function validateLocality(object, args) { if (document.getElementById(<%=ddlLocality.ClientID %>).value ==
I have the following javascript function fadeIn(objectID, amount) { object = document.getElementById(objectID + 'Des');
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; var valid
I have following Javascript line in my ASP.NET web app: document.getElementById('<%=myTextBox[0].ClientID %>').value = test;
I have the following JavaScript in my site : $(function() { var $cells =
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();

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.