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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:46:19+00:00 2026-06-11T10:46:19+00:00

i have a problem. I am trying to add a functions return value to

  • 0

i have a problem. I am trying to add a functions return value to a variable but it says the function is undefined. Here is my code. :

var selectedExpenseList = getSelectedExpenseIDs();

here is my function:

    function getSelectedExpenseIDs() {
            var selectedExpensesList = new Array;
            var i = 0;
            $('.expenseCheckBox:checked').each(function () {
                if ($(this)[0].id !== "checkAllExpenses") {
                    selectedExpensesList[i] = $(this)[0].id.split('_')[1];
                    ++i;
                }
            });
            return selectedExpensesList;
        }

EDIT: here is my entire function: I am trying to delete something from a list if a person has checked it.

     var selectedExpenseList;
 function actuallyDeleteTheExpense(canDeleteExpenses) 
 {
     selectedTasksList = getSelectedTaskIDs();
     var deleteTrackers = false, deleteExpenses = false;


     if (canDeleteExpenses && !canDeleteTrackers) 
     {
         $.Zebra_Dialog('Do you wish to remove Expenses?', 
         {
             'type': 'question',
             'title': 'Confirmation',
             'buttons': [
                        {
                            caption: 'Yes', callback: function () {
                                deleteTrackers = false;
                                deleteExpenses = true;
                                doTheDelete(deleteExpenses);
                            }
                        },

                        {
                            caption: 'No',
                            callback: function () {
                                doTheDelete(deleteExpenses);
                            }
                        }
                    ]
         });
     }
            }
            function doTheDelete(doIDeleteExpenses) 
            {
                if (selectedTasksList.length > 0) 
                {
                    $.ajax({
                        type: "POST",
                        //url: "/Tasks/ViewTasks.aspx/deleteTasksAndLinkedItems",
                        url: '<%=ResolveUrl("~/Expenses/ViewExpenses.aspx/deleteSelectedExpense")%>',
                        data: "{ 'TaskIDs': [" + selectedTasksList.join(',') + "], DeleteTrackers : " + doIDeleteTrackers + ", DeleteExpenses : " + doIDeleteExpenses + " }",
                        //fix data
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            var ss = data.d;
                            if (ss.length > 0) {
                                for (var i = 0; i < ss.length; ++i) {
                                    $.noty.consumeAlert({ layout: 'center', type: 'error', dismissQueue: true });
                                    alert(ss[i]);

                                }
                            }
                            $("#viewTasksGrid").flexReload();
                        },
                        error: function (data) {
                            $.noty.consumeAlert({ layout: 'center', type: 'error', dismissQueue: true, modal: true });
                            alert('Error Deleting Tasks');
                            if (window.console) {
                                console.log(data);
                            }
                        }
                    });
                } else {
                    showMessage('No tasks are selected.');
                }
            }
//end delete expense


        function getSelectedExpenseIDs() {
            var selectedExpensesList = new Array;
            var i = 0;
            $('.expenseCheckBox:checked').each(function () {
                if ($(this)[0].id !== "checkAllExpenses") {
                    selectedExpensesList[i] = $(this)[0].id.split('_')[1];
                    ++i;
                }
            });
            return selectedExpensesList;
        }
  • 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-11T10:46:20+00:00Added an answer on June 11, 2026 at 10:46 am

    I noticed that your function code is tabbed once more than your code that calls it. It’s possible that your function is scoped improperly (e.g. it’s declared inside another function and you’re calling it from outside that function).

    If your function is coming back as undefined, it’s almost certainly a scoping issue. I see nothing wrong with the function itself.

    For instance:

    $(document).ready(function () {
        function myFunction() { 
            return 3;
        } 
    });
    
    var bob = myFunction(); //Error: myFunction is not defined.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my problem. I am trying to add instrumentation to my code which
I have a problem trying to turn my python code into an executable using
I have a problem trying to select the default value in a ComboBox (html
i have a problem. I am trying to delete something from a list but
I have a problem trying to register my own Event/Listener to the event dispatcher.
I have a problem trying to design some generic storage.. Basically I have the
I have a problem trying to edit. I work with Areas for better management
I have a problem trying to hide .php extension from the url I have
I implemented the table sorter yesterday and i have a problem trying to change
I have a problem when trying to count in PHP using a button and

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.