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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:48:31+00:00 2026-05-25T09:48:31+00:00

I have JavaScript that basically looks like the following function a() { b(1); }

  • 0

I have JavaScript that basically looks like the following

function a() {
    b(1);
}

function b(myNumber) {
    c(myNumber);
}

function c(myNumber) {
    var calculation = 5 * (myNumber - 1);
    alert(calculation);
}

When I call the function a(), the alert box ends up saying “NaN”. Why is this happening? I’ve tried using the parseInt() function in a number of places, but nothing seems to work.

EDIT

Full code (what’s actually being done rather than a stripped down example):

function updateTablePagination(tableId, rowsPerPageSelectId) {
    updateTablePagination(tableId, rowsPerPageSelectId, 1);
}

function updateTablePagination(tableId, rowsPerPageSelectId, pageNumber) {
    var table = document.getElementById(tableId);
    var rowsPerPageSelect = document.getElementById(rowsPerPageSelectId);
    var rowsPerPage = rowsPerPageSelect.options[rowsPerPageSelect.selectedIndex].text;

    updateTable(table, rowsPerPage, pageNumber);
    //updateTablePageLinks();
}

function updateTable(table, rowsPerPage, pageNumber) {
    var tableRows = table.getElementsByTagName("tr");
    var totalNumberOfRows = tableRows.length;

    var startRow = rowsPerPage * (pageNumber - 1);      
     var endRow = Math.min(startRow + rowsPerPage, totalNumberOfRows - 1);

    alert("Start: " + startRow + "\nEnd: " + endRow);
}

A select box has an onchange calling updateTablePagination('myTableId', 'rowsPerPage'). The ids are both correct.

“Start” and “End” are both NaN.

Edit 2

Alternatively, if I just do alert(pageNumber), it is undefined.

Simplified

Even this says pageNumber is undefined:

function updateTablePagination(tableId, rowsPerPageSelectId) {
    updateTablePagination(tableId, rowsPerPageSelectId, 1);
}

function updateTablePagination(tableId, rowsPerPageSelectId, pageNumber) {
    alert(pageNumber);
}
  • 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-25T09:48:31+00:00Added an answer on May 25, 2026 at 9:48 am

    You have two functions called updateTablePagination. Javascript does not support function overloading. Get rid of the first declaration, because it is getting overwritten with the second. You can use the || to define a default value for the parameter.

    function updateTablePagination(tableId, rowsPerPageSelectId, pageNumber) {
        pageNumber = pageNumber || 1; //Set a default value for pageNumber
        var table = document.getElementById(tableId);
        var rowsPerPageSelect = document.getElementById(rowsPerPageSelectId);
        var rowsPerPage = rowsPerPageSelect.options[rowsPerPageSelect.selectedIndex].text;
    
        updateTable(table, rowsPerPage, pageNumber);
        //updateTablePageLinks();
    }
    
    
    updateTablePagination(tableId, rowsPerPageSelectId) //Will call the function with pageNumber == 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a javascript hash (object?) we will call settings_hash that basically looks like
Ok, I have one JavaScript that creates rows in a table like this: function
I basically have a form that you input chat messages into. It looks like
So I have a JSON variable that looks like this: var peopleList = {
I have a Javascript object that basically represents a Row in an .NET GridView.
Does jquery/javascript have any event model that you can attach to your objects? Basically
I have a javascript that calls a function each 1 minute. That function sends
I have a javascript that does this (http is your XMLHttpRequest object) var r
I have a table that looks like this: <table name=exercises id=workout-table> <tr> <th>Name</th> <th>Reps/Intervals</th>
I have some simple javascript that I'd like to run when a button is

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.