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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:14:55+00:00 2026-05-15T22:14:55+00:00

I have an onchange event that updates a form, and in the updating process

  • 0

I have an onchange event that updates a form, and in the updating process it calls a function to calculate shipping. I’m not sure why, but I’m getting the following error when I try to call the function:

Uncaught TypeError: number is not a function

The function, shipping, looks like this:

function shipping( weight )
{
    var flat

    switch( weight )
    {
        case 1:
        case 2:
        case 3:
            flat = 32.00;
            break;

        case 4:
            flat = 18.50;
            break;

        case 5:
            flat = 15.80;
            break;

        case 6:
            flat = 14.00;
            break;

        case 7:
            flat = 12.71;
            break;

        case 8:
            flat = 11.75;
            break;

        case 9:
            flat = 11.00;
            break;

        case 10:
            flat = 10.40;
            break;

        case 11:
            flat = 9.91;
            break;

        case 12:
            flat = 9.50;
            break;

        case 13:
            flat = 9.15;
            break;

        case 14:
            flat = 8.86;
            break;

        case 15:
            flat = 8.86;
            break;

        case 16:
            flat = 8.38;
            break;

        case 17:
            flat = 8.18;
            break;

        case 18:
            flat = 8.00;
            break;

        case 19:
            flat = 7.84;
            break;

        case 20:
            flat = 7.70;
            break;

    } // switch

    var flat_fee = flat * weight;
    var mile_fee = distance * 0.90;

    var shipping_fee = flat_fee + mile_fee;
    simpleCart.shippingTest = shipping_fee;
    return shipping_fee;
} // shipping

I’m passing in 1 right now. The variable distance is coming from an ajax call that is completed before this function is run. That function looks like this:

function get_distance( zip )
{

    $.getJSON(
        'distance.php',
        { zip:zip },
        function(json)
        {
            distance = json 
        })

} // get_distance

I’ve checked to make sure the variable distance is set.

The console says the uncaught type error is happing at the line where I call shipping(1). Any thoughts as to why that’s happening?

  • 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-15T22:14:56+00:00Added an answer on May 15, 2026 at 10:14 pm

    Are you using shipping as a variable anywhere? Sounds like the function shipping is getting overwritten by using it as a variable with a numeric value of 1.

    It’s not in the code you posted (neither is the call to shipping(1) you mentioned).

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

Sidebar

Related Questions

I have a javascript that runs using the onchange event when a user enteres
I have a javascript that is executed with the onchange event. onchange=showUser(1, this.value) The
I have a textbox with an onchange event. Why does this event not fire
I have this code which is called at an onChange event of an function
I have a Javascript function that is called from the onchange method in a
I have a form that jQuery tracks the onChage .change() event so when something
I have some code that I have created for an OnChange event which works
I've got a problem with XMLHttpRequest. I have a that has a onChange event
i have a function call it: myFunction(A,B,C) I have onchange event in my option
I have the following code in the OnChange() event for a field. alert(alert text);

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.